#include <pspsdk.h>
#include "mpeg_vsh.h"

//Imports from library: ThreadManForUser
extern int sceKernelcheckThreadStack();
extern int sceKernelCreateSema (int arg1, int arg2, int arg3, int arg4, int arg5);
extern int sceKernelDeleteSema ();
extern int sceKernelSignalSema (int arg1, int arg2);
extern int sceKernelWaitSema (int arg1, int arg2, int arg3);
extern void sceKernelPollSema ();
extern void sceKernelReferSemaStatus ();
//Imports from library: UtilsForUser
extern void sceKernelDcacheWritebackInvalidateRange (int arg1, int arg2);
//Imports from library: sceVideocodec
extern int sceVideocodecInit (int arg1, int arg2);
extern int sceVideocodecGetFrameCrop (int arg1, int arg2);
extern int sceVideocodecGetVersion (int arg1, int arg2);
extern int sceVideocodecGetEDRAM (int arg1, int arg2);
extern int sceVideocodecDelete (int arg1, int arg2);
extern void sceVideocodecReleaseEDRAM (int arg1);
extern int sceVideocodecGetSEI (int arg1, int arg2);
extern int sceVideocodecSetMemory (int arg1, int arg2);
extern int sceVideocodec_893B32B1 (int arg1, int arg2);
extern int sceVideocodecStop (int arg1, int arg2);
extern int sceVideocodecOpen (int arg1, int arg2);
extern int sceVideocodecDecode (int arg1, int arg2);
//Imports from library: sceAudiocodec
extern void sceAudiocodecReleaseEDRAM ();
extern int sceAudiocodecGetEDRAM (int arg1, int arg2);
extern int sceAudiocodecInit (int arg1, int arg2);
extern int sceAudiocodecDecode (int arg1, int arg2);
extern int sceAudiocodecCheckNeedMem (int arg1, int arg2);
//Imports from library: sceMpegbase
extern void sceMpegbase_0530BE4E (int arg1);
extern int sceMpegBaseCscAvcRange (int arg1, int arg2, int arg3, int arg4, int arg5);
extern int sceMpegBaseCscInit (int arg1);
extern int sceMpegBaseYCrCbCopy (int arg1, int arg2, int arg3);
extern int sceMpegBaseCscAvc (int arg1, int arg2, int arg3, int arg4);
extern int sceMpegbase_BEA18F91 (int arg1);

int mpegIsInit;//0x0000A240
int stream;//0x0000A1A4
char*pAudioCodecStruct;//0x0000A380
char audioCodecStruct[0x6C];//0x0000A3C0
char*pVideoCodecStruct;
char videoCodecStruct[0x60];//0x0000A2C0
int mpegAvcSema;//0x0000A444
int mpegAtracSema;//0x0000A448
int mpegLibmpegSema;//0x0000A44C

int mpegFlushStream (int arg1, int arg2){
  sp = sp + 0xFFFFFFD0;
  ((int *) sp)[6] = s2;
  ((int *) sp)[5] = s1;
  ((int *) sp)[4] = s0;
  var1 = arg2;
  ((int *) sp)[8] = ra;
  ((int *) sp)[7] = s3;
  var2 = ((int *) arg1)[0];
  var5 = checkMpegLib (arg1);
  if(var5 == 0)
  {
    var10 = ((int *) var2)[411];
    waitSema ();
    var13 = ((int *) arg1)[0];
    var14 = ((int *) var1)[0];
    var17 = unRegistStream (var14, var13, 1);
    var18 = var17;
    var19 = sp;
    var20 = sp + 4;
    if(var17 == 0xFFFFFFFF)
    {
      var34 = ((int *) var2)[411];
      signalSema ();
      var5 = 0x806101FE;
    }
    else
    {
      var21 = ((int *) var17)[2];
      if(!(var21 == 0xFFFFFFFF))
      {
        var22 = ((int *) var1)[2];
        ((int *) var18)[3] = 0;
        ((int *) var18)[0] = 0xFFFFFFFF;
        ((int *) var18)[1] = 0xFFFFFFFF;
        if(!(var22 == 0xFFFFFFFF))
        {
          ((int *) var22)[3] = 0;
          ((int *) var22)[1] = 0xFFFFFFFF;
          ((int *) var22)[0] = 0xFFFFFFFF;
        }
      }
      ((int *) var1)[4] = 0x00007FFF;
      var23 = ((int *) var1)[0];
      ((int *) var1)[11] = 0;
      flushStream (var19, var20, var23);
      var26 = ((int *) sp)[0];
      var27 = (var26 << 3) + 0x00009FCC;
      var28 = ((int *) var1)[12];
      var29 = ((int *) var27)[1];
      var30 = ((int *) var27)[0];
      ((int *) var1)[10] = var30;
      ((int *) var1)[5] = var29;
      ((int *) var1)[6] = 1;
      ((int *) var1)[12] = ((var28 & 0xFFFFFFFB) | (0 & 1));
      ((int *) var1)[16] = 0;
      ((int *) var1)[8] = 0;
      ((int *) var1)[13] = 0;
      ((int *) var1)[14] = 0;
      var31 = ((int *) var2)[411];
      signalSema ();
      var5 = var5;
    }
  }
  ra = ((int *) sp)[8];
  var6 = ((int *) sp)[7];
  var7 = ((int *) sp)[6];
  var8 = ((int *) sp)[5];
  var9 = ((int *) sp)[4];
  sp = sp + 0x30;
  return var5;
}
int mpegFlushAllStream (int arg1){
  sp = sp + 0xFFFFFFE0;
  ((int *) sp)[2] = s2;
  ((int *) sp)[4] = ra;
  ((int *) sp)[3] = s3;
  ((int *) sp)[1] = s1;
  ((int *) sp)[0] = s0;
  var1 = ((int *) arg1)[0];
  var4 = checkMpegLib (arg1);
  var5 = var4;
  if(!(var4 != 0))
  {
    var6 = 0;
    var7 = ((int *) var1)[6];
    while (1) {
      var6 = var6 + 1;
      var8 = ((int *) ((var6 << 4) + var7))[2];
      if(var8 == 0xFFFFFFFF)
      {
      label10:
        if(!(((var6 < 0x70)) != 0))
          break;
        var7 = ((int *) var1)[6];
        continue;
      }
      else
      {
        var11 = mpegFlushStream (arg1, var8);
        var5 = var11;
        if(var11 != 0)
          break;
        goto label10;
      }
    }
  }
  ra = ((int *) sp)[4];
  var12 = ((int *) sp)[3];
  var13 = ((int *) sp)[2];
  var14 = ((int *) sp)[1];
  var15 = ((int *) sp)[0];
  sp = sp + 0x20;
  return var5;
}
int mpegUnRegistStream (int arg1, int arg2){
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[1] = s1;
  var1 = arg2;
  ((int *) sp)[2] = ra;
  ((int *) sp)[0] = s0;
  var2 = ((int *) arg1)[0];
  var5 = checkMpegLib (arg1);
  var6 = var5;
  if(var5 == 0)
  {
    var9 = ((int *) var2)[411];
    waitSema ();
    var12 = ((int *) var1)[0];
    var15 = unRegistStream (var12, var2, 1);
    if(var15 == 0xFFFFFFFF)
    {
      var21 = ((int *) var2)[411];
      signalSema ();
      var6 = 0x806101FE;
    }
    else
    {
      var16 = ((int *) var15)[2];
      if(!(var16 == 0xFFFFFFFF))
      {
        var17 = ((int *) var1)[2];
        ((int *) var15)[3] = 0;
        ((int *) var15)[2] = 0xFFFFFFFF;
        ((int *) var15)[0] = 0xFFFFFFFF;
        ((int *) var15)[1] = 0xFFFFFFFF;
        if(!(var17 == 0xFFFFFFFF))
        {
          ((int *) var17)[3] = 0;
          ((int *) var17)[1] = 0xFFFFFFFF;
          ((int *) var17)[2] = 0xFFFFFFFF;
          ((int *) var17)[0] = 0xFFFFFFFF;
        }
      }
      var18 = ((int *) var2)[411];
      signalSema ();
      var6 = 0;
    }
  }
  ra = ((int *) sp)[2];
  var7 = ((int *) sp)[1];
  var8 = ((int *) sp)[0];
  sp = sp + 0x10;
  return var6;
}
int mpegRegistStream (int arg1, int arg2, int arg3){
  sp = sp + 0xFFFFFFE0;
  ((int *) sp)[5] = s5;
  var1 = 0xFFFFFFFF;
  ((int *) sp)[4] = s4;
  ((int *) sp)[2] = s2;
  var2 = arg3;
  ((int *) sp)[1] = s1;
  var3 = arg2;
  ((int *) sp)[6] = ra;
  ((int *) sp)[3] = s3;
  ((int *) sp)[0] = s0;
  var4 = ((int *) arg1)[0];
  var7 = checkMpegLib (arg1);
  var8 = 0;
  if(!(var7 != 0))
  {
    var9 = ((int *) var4)[411];
    waitSema ();
    var14 = getStream (var3, var2);
    var17 = unRegistStream (var14, var4, 2);
    if(var17 == 0xFFFFFFFF)
    {
    label17:
      var31 = ((int *) var4)[411];
      signalSema ();
      var8 = 0;
    }
    else
    {
      if(!(var3 != 0))
      {
        var18 = ((int *) var4)[8];
        var1 = var18 + (var2 << 0x0B);
      }
      var21 = sub_00CC0 (arg1, var3, var2, var1, var17);
      if(var21 != 0)
        goto label17;
      var22 = ((int *) var4)[411];
      signalSema ();
      var8 = var17;
    }
  }
  ra = ((int *) sp)[6];
  var25 = ((int *) sp)[5];
  var26 = ((int *) sp)[4];
  var27 = ((int *) sp)[3];
  var28 = ((int *) sp)[2];
  var29 = ((int *) sp)[1];
  var30 = ((int *) sp)[0];
  sp = sp + 0x20;
  return var8;
}
int mpegInit (){
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[0] = ra;
  var1 = mpegIsInit;
  var2 = 0x80618005;
  if(!(var1 != 0))
  {
    mpegIsInit = 1;
    var5 = createSema (1, 1, "SceMpegLibmpeg", mpegLibmpegSema);
    var2 = 0x80618006;
    if(!(var5 != 0))
    {
      var8 = createSema (1, 1, "SceMpegAvc", mpegAvcSema);
      var2 = 0x80618006;
      if(!(var8 != 0))
      {
        var11 = createSema (1, 1, "SceMpegAtrac", mpegAtracSema);
        var2 = 0x80618006;
        if(!(var11 != 0))
        {
          initAudioCodec ();
          initVideoCodec (0);
          initVSH ();
          var2 = 0;
        }
      }
    }
  }
  ra = ((int *) sp)[0];
  sp = sp + 0x10;
  return var2;
}
int mpegFinish (){
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[0] = ra;
  var1 = mpegIsInit;
  var2 = 0x80618005;
  if(!(var1 == 0))
  {
    mpegIsInit = 0;
    audiocodecReleaseEDRAM ();
    videocodecReleaseEDRAM ();
    var7 = *((int *) mpegLibmpegSema);
    var10 = deleteSema ();
    var2 = 0x80618006;
    if(!(var10 != 0))
    {
      var11 = *((int *) mpegAvcSema);
      var14 = deleteSema ();
      var2 = 0x80618006;
      if(!(var14 != 0))
      {
        var15 = *((int *) mpegAtracSema);
        var18 = deleteSema ();
        var2 = !(var18) ? 0 : 0x80618006;
      }
    }
  }
  ra = ((int *) sp)[0];
  sp = sp + 0x10;
  return var2;
}
int mpegQueryMemSize (int arg1){
  if(sub_085D8()){
    var5 = sp[0];
	}else{
    if(!sub_08588 (sp))var5 = sp[0];
	}
	((int *) sp)[0] = ((((var5 + 0x3F) & 0xFFFFFFC0) | (0 & 0x3F)) + 0x0000023F);
	if((((arg1 + 0xFFFFFFFD) < 4)) != 0)
	{
		var33 = sub_08F70 ();
		var34 = ((int *) sp)[0];
		((int *) sp)[0] = ((var34 + var33) + 0x00000640);
	}
	if(((((arg1 ^ 1) < 1)) | (((arg1 ^ 4) < 1))) != 0)
	{
	label36:
		((int *) sp)[2] = 0;
		var8 = sub_09330 (0);
		if(var8 != 0)
		{
			audiocodecReleaseEDRAM ();
			var9 = ((int *) sp)[2];
		}
		else
		{
		label42:
			var9 = ((int *) sp)[2];
		}
	label43:
		var10 = ((int *) sp)[0];
		var11 = (((var9 + 0x3F) & 0xFFFFFFC0) | (0 & 0x3F)) + 0x80;
		((int *) sp)[2] = var11;
		var12 = (0x0000B2F0 + (var10 + var11)) + 0x00000100;
		ra = ((int *) sp)[6];
	}
	else
	{
		if(!(((((arg1 ^ 0x05) < 1)) | (((arg1 ^ 0x06) < 1))) == 0))
			goto label36;
		var17 = sp + 4;
		var20 = sub_09330 (var17);
		if(var20 == 0)
		{
		label28:
			var27 = initVideoCodec (arg1);
			if(var27 != 0)
			{
				var28 = sp + 8;
				var12 = sub_092D0 (var28, arg1);
				ra = ((int *) sp)[6];
				if(!(var12 != 0))
				{
					var9 = ((int *) sp)[2];
					goto label43;
				}
			}
			else
			{
			label35:
				((int *) sp)[2] = 0;
				goto label42;
			}
		}
		else
		{
			if(arg1 != 0)
			{
			label23:
				var22 = ((int *) sp)[1];
				if(arg1 == 3)
				{
					if(var22 != 1)
					{
					label26:
						audiocodecReleaseEDRAM ();
						goto label28;
					}
					else
					{
						((int *) sp)[2] = 0;
						goto label35;
					}
				}
				else
				goto label26;
			}
			else
			{
				var21 = ((int *) sp)[1];
				if(var21 == 0)
				{
					((int *) sp)[2] = 0;
					goto label35;
				}
				else
				{
					goto label23;
				}
			}
		}
	}
  return var12;
}
int mpegCreate (int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7){
  var1 = arg1;
  var2 = arg6;
  var3 = arg4;
  ((int *) sp)[7] = arg3;
  ((int *) sp)[6] = arg2;
  ((int *) sp)[8] = arg5;
  ((int *) sp)[9] = arg7;
  var6 = mpegQueryMemSize (arg6);
  var8 = 0x80610022;
  if(!(((arg3 < var6)) != 0))
  {
    var9 = *((int *) mpegLibmpegSema);
    var10 = arg2;
    waitSema ();
    var13 = arg3;
    memset (var10, 0, var13);
    var18 = ((var10 + 0x3F) & 0xFFFFFFC0) | (0 & 0x3F);
    ((int *) var1)[0] = var18;
    ((int *) var18)[3] = 0xFFFFFFFF;
    ((int *) var18)[0] = *((int *) 0x00009F94);
    var19 = var18;
    ((int *) var18)[1] = *((int *) 0x00009F98);
    ((int *) var18)[2] = 0x00313030;
    ((int *) var18)[414] = var2;
    var22 = createSema (1, 1, "SceMpegMpegData", (var18 + 0x0000066C));
    if(var22){
			signalSema (mpegLibmpegSema);
			return 0x80618006;
    }
		var23 = (((var18 + 0x000006E8) + 0x3F) & 0xFFFFFFC0);
		((int *) var19)[6] = var23;
		var24 = ((int *) var3)[8];
		((int *) var19)[4] = var3;
		((int *) var19)[5] = var24;
		var25 = ((int *) var19)[6];
		((int *) var3)[10] = var1;
		var26 = 0x6F;
		while (1) {
			var26 = var26 + 0xFFFFFFFF;
			((int *) var25)[0] = 0xFFFFFFFF;
			((int *) var25)[1] = 0xFFFFFFFF;
			((int *) var25)[2] = 0xFFFFFFFF;
			((int *) var25)[3] = 0;
			var25 = var25 + 0x10;
			if(var26 >= 0)
				continue;
			break;
		}
		var27 = (((var23 + 0x00000704) + 0x3F) & 0xFFFFFFC0) | (0 & 0x3F);
		((int *) var19)[7] = var27;
		var28 = 0x6E;
		while (1) {
			if(!(var28 >= 0))
				break;
			var28 = var28 + 0xFFFFFFFF;
			continue;
		}
		var29 = (((var27 + 0x00001DC4) + 0x3F) & 0xFFFFFFC0) | (0 & 0x3F);
		((int *) var19)[8] = var29;
		memset (var29, 0, 0x00008000);
		((int *) var19)[9] = 0;
		var32 = 0;
		var33 = var19;
		while (1) {
			((int *) var33)[10] = 0x63;
			var34 = var33 + 0x2C;
			var35 = 0;
			var36 = var34;
			while (1) {
				var37 = var36 + 0x10;
				sub_05A7C (var36, 0, 0, var37, 0);
				var40 = ((int *) var33)[10];
				var35 = var35 + 1;
				var36 = var37;
				if(((var35 < var40)) != 0)
					continue;
				break;
			}
			var32 = var32 + 1;
			sub_05AB0 (((var34 + (var35 << 4)) + 0xFFFFFFF0), 0);
			var33 = var33 + 0x00000644;
			if(var32 <= 0)
				continue;
			break;
		}
		var43 = ((((var29 + 0x00008000) + 0x00000644) + 0x3F) & 0xFFFFFFC0) | (0 & 0x3F);
		var44 = var43 + 0x80;
		var45 = var44 + 0x40;
		var46 = var2 + 0xFFFFFFFD;
		var47 = var45 + 0xC0;
		((int *) var19)[419] = var43;
		var48 = var47 + 0x80;
		((int *) var19)[420] = var44;
		((int *) var19)[421] = var45;
		((int *) var19)[422] = var47;
		if(((var46 < 4)) != 0)
		{
			var113 = var48 + 0x00000540;
			var114 = var113 + 0xC0;
			((int *) var19)[423] = var48;
			var115 = var114 + 0x40;
			((int *) var19)[431] = var113;
			((int *) var19)[432] = var114;
			sub_08F78 ((var19 + 0x000006A0), var115);
			var120 = sub_08F70 ();
			var121 = ((int *) var19)[424];
			var48 = var115 + var120;
			sub_08FE0 (var121);
		}
		var51 = sub_085D8 ();
		((int *) var19)[425] = var51;
		if(var51 == 0)
		{
			((int *) var19)[425] = var48;
			var108 = sp + 0x10;
			var111 = sub_08588 (var108);
			var69 = var111;
			if(var111 != 0)
			{
			label68:
				var104 = *((int *) mpegLibmpegSema);
			}
			else
			{
				var112 = ((int *) sp)[4];
				var48 = var48 + (((var112 + 0x3F) & 0xFFFFFFC0) | (0 & 0x3F));
			label45:
				if(((var46 < 4)) != 0)
				{
					((char *) var19)[1665] = 1;
					((int *) var19)[415] = 0;
					((char *) var19)[1664] = 1;
					((int *) var19)[417] = 0;
					((int *) var19)[418] = 0;
				}
				else
				{
					((char *) var19)[1664] = 0;
					((char *) var19)[1665] = 0;
					var52 = ((int *) sp)[9];
					((int *) var19)[415] = 2;
					((int *) var19)[417] = 0x0004A000;
					((int *) var19)[418] = 0x00062400;
					if(var52 == 0)
					{
						((int *) sp)[9] = 0x09000000;
					}
				}
				var53 = ((int *) sp)[9];
				if(((var2 < 0x07)) == 0)
				{
				label54:
					((int *) var19)[427] = 0x000001E0;
					((int *) var19)[428] = 0x00000110;
					((int *) var19)[429] = 2;
					((int *) var19)[426] = var53;
				label57:
					((int *) var19)[430] = 0;
				}
				else
				{
					var54 = ((int *) ((var2 << 2) + 0x0000A040))[0];
					switch () {
					case 0:
						var55 = ((int *) sp)[9];
						((int *) var19)[427] = 0x000001E0;
						((int *) var19)[428] = 0x00000110;
						((int *) var19)[429] = 2;
						((int *) var19)[426] = var55;
						goto label57;
					case 1:
					case 4:
						var105 = arg7;
						((int *) var19)[427] = 0x000001E0;
						((int *) var19)[428] = 0x00000110;
						((int *) var19)[429] = 3;
						((int *) var19)[426] = var105;
						goto label57;
					case 2:
						var53 = ((int *) sp)[9];
						goto label54;
					case 3:
					case 5:
						var106 = ((int *) sp)[9];
						((int *) var19)[427] = 0x000002D0;
						((int *) var19)[428] = 0x000001E0;
						((int *) var19)[429] = 3;
						((int *) var19)[430] = 1;
						((int *) var19)[426] = var106;
						goto label58;
					case 6:
						var107 = ((int *) sp)[9];
						((int *) var19)[427] = 0x000002D0;
						((int *) var19)[428] = 0x00000240;
						((int *) var19)[429] = 3;
						((int *) var19)[430] = 1;
						((int *) var19)[426] = var107;
						goto label58;
					}
				}
			label58:
				var56 = ((int *) var19)[428];
				var57 = ((int *) var19)[429];
				var58 = ((int *) var19)[430];
				var59 = ((int *) var19)[419];
				var60 = ((int *) var19)[420];
				var61 = ((int *) var19)[421];
				var62 = ((int *) var19)[422];
				var63 = ((int *) var19)[423];
				var64 = ((int *) var19)[426];
				var65 = ((int *) var19)[427];
				((int *) sp)[0] = var56;
				((int *) sp)[1] = var57;
				((int *) sp)[2] = var58;
				var68 = sub_083E4 (var59, var60, var61, var62, var63, (var19 + 0x000006A4), var64, var65);
				var69 = var68;
				if(var68 != 0)
					goto label68;
				if((((var2 + 0xFFFFFFFC) < 3)) == 0)
				{
				label65:
					var74 = ((int *) sp)[8];
					var77 = sceMpegBaseCscInit (var74);
					var69 = var77;
					if(var77 != 0)
						goto label68;
					var78 = var2 ^ 1;
					var79 = var2 ^ 4;
					if((((var78 < 1)) | ((var79 < 1))) != 0)
					{
						((int *) var19)[440] = 0;
					label79:
						((int *) var19)[439] = 0;
					label80:
						if((((var78 < 1)) | ((var79 < 1))) != 0)
						{
							((int *) var19)[438] = 0;
						}
						else
						{
							if(((((var2 ^ 0x05) < 1)) | (((var2 ^ 0x06) < 1))) == 0)
							{
								var96 = sub_09330 (0);
								((int *) var19)[438] = var96;
								if(!(var96 != 0))
								{
									var97 = ((int *) sp)[5];
									((int *) var19)[438] = var48;
									var48 = var48 + (((var97 + 0x3F) & 0xFFFFFFC0) | (0 & 0x3F));
								}
							}
							else
							{
								((int *) var19)[438] = 0;
							}
						}
						var80 = ((int *) sp)[6];
						var81 = ((int *) sp)[7];
						var82 = *((int *) mpegLibmpegSema);
						var69 = !(((var48 < (var80 + var81)))) ? 0x80610022 : var69;
					}
					else
					{
						if(((((var2 ^ 0x05) < 1)) | (((var2 ^ 0x06) < 1))) == 0)
						{
							((int *) var19)[440] = var48;
							var98 = sp + 0x14;
							var101 = sub_092D0 (var98, var2);
							var69 = var101;
							var48 = var48 + 0x80;
							if(var101 != 0)
							{
							label76:
								var103 = *((int *) mpegLibmpegSema);
							}
							else
							{
								var102 = ((int *) sp)[5];
								((int *) var19)[439] = var102;
								goto label80;
							}
						}
						else
						{
							((int *) var19)[440] = 0;
							goto label79;
						}
					}
				}
				else
				{
					var70 = ((int *) var19)[419];
					var73 = sub_087B8 (var70, 1);
					var69 = var73;
					if(var73 != 0)
						goto label76;
					goto label65;
				}
			}
		}
		else
		goto label45;
		signalSema ();
		var8 = var69;
	
  }
  return var8;
}
int mpegDelete (int arg1){
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[0] = s0;
  ((int *) sp)[3] = ra;
  ((int *) sp)[2] = s2;
  ((int *) sp)[1] = s1;
  var1 = ((int *) arg1)[0];
  var4 = checkMpegLib (arg1);
  if(var4 == 0)
  {
    var8 = ((int *) var1)[419];
    delete (var8);
    var11 = *((int *) mpegLibmpegSema);
    waitSema ();
    var14 = ((int *) var1)[6];
    var15 = 0x6F;
    while (1) {
      var15 = var15 + 0xFFFFFFFF;
      ((int *) var14)[0] = 0xFFFFFFFF;
      ((int *) var14)[1] = 0xFFFFFFFF;
      ((int *) var14)[2] = 0xFFFFFFFF;
      ((int *) var14)[3] = 0;
      var14 = var14 + 0x10;
      if(var15 >= 0)
        continue;
      break;
    }
    var16 = ((int *) var1)[411];
    var19 = deleteSema ();
    if(var19 != 0)
    {
      var23 = *((int *) mpegLibmpegSema);
      signalSema ();
      var4 = 0x80618006;
    }
    else
    {
      var20 = *((int *) mpegLibmpegSema);
      signalSema ();
      var4 = var4;
    }
  }
  ra = ((int *) sp)[3];
  var5 = ((int *) sp)[2];
  var6 = ((int *) sp)[1];
  var7 = ((int *) sp)[0];
  sp = sp + 0x10;
  return var4;
}
int mpegInitAu (int arg1, int arg2, int arg3){
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[1] = s1;
  var1 = arg3;
  ((int *) sp)[0] = s0;
  ((int *) sp)[2] = ra;
  var4 = checkMpegLib (arg1);
  var5 = var4;
  if(!(var4 != 0))
  {
    ((int *) var1)[4] = arg2;
    var5 = 0;
    ((int *) var1)[5] = 0;
  }
  ra = ((int *) sp)[2];
  var6 = ((int *) sp)[1];
  var7 = ((int *) sp)[0];
  sp = sp + 0x10;
  return var5;
}
int sub_00CC0 (int arg1, int arg2, int arg3, int arg4, int arg5){
  sp = sp + 0xFFFFFFE0;
  ((int *) sp)[4] = s4;
  var1 = arg3;
  ((int *) sp)[3] = s3;
  ((int *) sp)[2] = s2;
  var2 = arg2;
  ((int *) sp)[1] = s1;
  ((int *) sp)[0] = s0;
  var3 = arg5;
  ((int *) sp)[6] = ra;
  ((int *) sp)[5] = s5;
  var6 = checkMpegLib (arg1);
  var7 = var6;
  if(!(var6 != 0))
  {
    var7 = 0x806101FE;
    if(!(((var2 < 0x07)) == 0))
    {
      var8 = ((int *) arg1)[0];
      var11 = getStream (var2, var1);
      ((int *) var3)[0] = var11;
      var14 = getStreamOffset (var2);
      var15 = (var2 << 3) + 0x00009FCC;
      var16 = ((int *) var15)[1];
      var17 = ((int *) var15)[0];
      ((int *) var3)[4] = 0x00007FFF;
      ((int *) var3)[6] = 1;
      var18 = ((int *) var3)[0];
      ((int *) var3)[1] = var14;
      ((int *) var3)[3] = (!(var2) ? arg4 : 0);
      ((int *) var3)[10] = var17;
      ((int *) var3)[5] = var16;
      ((int *) var3)[11] = 0;
      ((int *) var3)[8] = 0;
      ((int *) var3)[13] = 0;
      ((int *) var3)[14] = 0;
      ((int *) var3)[12] = 0;
      ((int *) var3)[16] = 0;
      var21 = unRegistStream (var18, var8, 1);
      var22 = var21;
      var7 = 0x806101FE;
      if(!(var22 == 0xFFFFFFFF))
      {
        var23 = ((int *) var22)[2];
        var7 = 0x80618005;
        if(!(var23 != 0xFFFFFFFF))
        {
          ((int *) var22)[1] = var23;
          ((int *) var22)[2] = var3;
          ((int *) var22)[3] = 0;
          ((int *) var22)[0] = var23;
          if(var2 == 0)
          {
            var32 = getStream (0x06, var1);
            var35 = unRegistStream (var32, var8, 1);
            var7 = 0x806101FE;
            if(!(var35 == var23))
            {
              var36 = ((int *) var35)[2];
              var7 = 0x80618005;
              if(!(var36 != var23))
              {
                ((int *) var35)[1] = var23;
                ((int *) var3)[2] = var35;
                ((int *) var35)[2] = var3;
                ((int *) var35)[3] = 0;
                ((int *) var35)[0] = var23;
              label23:
                var7 = 0;
              }
            }
          }
          else
          {
            ((int *) var3)[2] = var23;
            goto label23;
          }
        }
      }
    }
  }
  ra = ((int *) sp)[6];
  var24 = ((int *) sp)[5];
  var25 = ((int *) sp)[4];
  var26 = ((int *) sp)[3];
  var27 = ((int *) sp)[2];
  var28 = ((int *) sp)[1];
  var29 = ((int *) sp)[0];
  sp = sp + 0x20;
  return var7;
}
int mpegAvcDecodeMode (int arg1, int arg2){
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[0] = s0;
  var1 = arg2;
  ((int *) sp)[2] = ra;
  ((int *) sp)[1] = s1;
  var2 = ((int *) arg1)[0];
  var3 = ((int *) var2)[419];
  var6 = checkMpegLib (arg1);
  var7 = var6;
  if(!(var6 != 0))
  {
    var8 = ((int *) var1)[0];
    if(var8 == 0xFFFFFFFF)
    {
    label9:
      var9 = ((int *) var1)[1];
      if(var9 == 0xFFFFFFFF)
      {
      label14:
        var7 = 0;
      }
      else
      {
        if(((var9 < 0xFFFFFFFF)) != 0)
        {
        label15:
        label16:
          var7 = 0x806101FE;
        }
        else
        {
          if(!(((var9 < 4)) != 0))
            goto label15;
          var12 = ((int *)(0x0000A05C)[var9];
          sceMpegbase_0530BE4E (var12);
          goto label14;
        }
      }
    }
    else
    {
      if(((var8 < 0xFFFFFFFF)) != 0)
        goto label15;
      if(((var8 < 3)) == 0)
        goto label16;
      ((int *) var3)[13] = var8;
      goto label9;
    }
  }
  ra = ((int *) sp)[2];
  var10 = ((int *) sp)[1];
  var11 = ((int *) sp)[0];
  sp = sp + 0x10;
  return var7;
}
int avcDecodeDetail (int arg1, int arg2, int arg3){
  sp = sp + 0xFFFFFFE0;
  ((int *) sp)[6] = s2;
  var1 = arg3;
  ((int *) sp)[5] = s1;
  var2 = arg2;
  ((int *) sp)[4] = s0;
  ((int *) sp)[7] = ra;
  var3 = arg1;
  var6 = checkMpegLib (arg1);
  var7 = var6;
  var8 = sp;
  if(var6 == 0)
  {
    var12 = ((int *) var3)[0];
    var15 = mpegAvcDecodeDetail2 (var3, var8);
    var7 = var15;
    if(var15 != 0)
    {
    label14:
      ra = ((int *) sp)[7];
    label15:
      var9 = ((int *) sp)[6];
    }
    else
    {
      var16 = ((int *) var12)[414];
      var17 = ((int *) sp)[0];
      var18 = ((int *) var17)[4];
      var7 = 0x806101FE;
      var19 = ((int *) var17)[11];
      if(!((((var16 + 0xFFFFFFFC) < 3)) == 0))
      {
        var18 = var18 + (((var2 << 2) + var2) << 3);
      }
      ra = ((int *) sp)[7];
      if(var2 < 0)
        goto label15;
      var20 = ((int *) var18)[8];
      if(((var2 < var20)) == 0)
      {
        var9 = ((int *) sp)[6];
      }
      else
      {
        var21 = ((int *) var17)[2];
        var7 = 0;
        ((int *) var1)[0] = var21;
        var22 = ((int *) (var19 + (var2 * 0x2C)))[8];
        ((int *) var1)[1] = var22;
        var23 = ((int *) var18)[2];
        ((int *) var1)[2] = var23;
        var24 = ((int *) var18)[3];
        ((int *) var1)[3] = var24;
        var25 = ((int *) var18)[4];
        ((int *) var1)[4] = var25;
        var26 = ((int *) var18)[5];
        ((int *) var1)[5] = var26;
        var27 = ((int *) var18)[6];
        ((int *) var1)[6] = var27;
        var28 = ((int *) var18)[7];
        ((int *) var1)[7] = var28;
        var29 = ((int *) var18)[8];
        ((int *) var1)[8] = var29;
        goto label15;
      }
    }
  }
  else
  goto label14;
  var10 = ((int *) sp)[5];
  var11 = ((int *) sp)[4];
  sp = sp + 0x20;
  return var7;
}
int mpegAvcDecodeDetail2 (int arg1, int arg2){
  var3 = checkMpegLib (arg1);
  var4 = var3;
  if(!(var3 != 0))
  {
    var5 = ((int *) (*arg1)[0];
    var6 = (*arg1)[414];
    if((((var6 + 0xFFFFFFFC) < 3)) != 0)
    {
      var10 = (*arg1)[424];
      var7 = var10 + 0x2C;
    }
    else
    {
      var7 = (*arg1)[419];
    }
    ((int *) arg2)[0] = var7;
    var4 = 0;
  }
  return var4;
}
int mpegAvcDecodeGetDecodeSEI (int arg1, int arg2){
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[1] = s1;
  ((int *) sp)[0] = s0;
  ((int *) sp)[2] = ra;
  var3 = checkMpegLib (arg1);
  var4 = var3;
  if(!(var3 != 0))
  {
    var5 = ((int *) arg1)[0];
    var6 = ((int *) var5)[414];
    var4 = 0x806101FE;
    if(!((((var6 + 0xFFFFFFFD) < 4)) == 0))
    {
      var7 = ((int *) var5)[431];
      var8 = ((int *) var5)[419];
      ((int *) arg2)[0] = var7;
      var11 = sub_086F8 (var8, var7);
      var4 = var11;
    }
  }
  ra = ((int *) sp)[2];
  var12 = ((int *) sp)[1];
  var13 = ((int *) sp)[0];
  sp = sp + 0x10;
  return var4;
}
int mpeg_AE693D0B (int arg1, int arg2){
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[1] = s1;
  ((int *) sp)[0] = s0;
  ((int *) sp)[2] = ra;
  var3 = checkMpegLib (arg1);
  var4 = var3;
  if(!(var3 != 0))
  {
    var5 = ((int *) arg1)[0];
    var6 = ((int *) var5)[414];
    var4 = 0x806101FE;
    if(!((((var6 + 0xFFFFFFFD) < 4)) == 0))
    {
      var7 = ((int *) var5)[432];
      var8 = ((int *) var5)[419];
      ((int *) arg2)[0] = var7;
      var11 = sub_08758 (var8, var7);
      var4 = var11;
    }
  }
  ra = ((int *) sp)[2];
  var12 = ((int *) sp)[1];
  var13 = ((int *) sp)[0];
  sp = sp + 0x10;
  return var4;
}
int mpegAvcDecode (int arg1, int arg2, int arg3, int arg4, int arg5){
  var1 = arg5;
  var2 = arg2;
  var3 = arg1;
  var6 = checkMpegLib (arg1);
  var7 = var6;
  if(var6 == 0)
  {
    var16 = ((int *) var3)[0];
    var17 = ((int *) var2)[4];
    var18 = ((int *) var16)[421];
    var19 = ((int *) var16)[419];
    var20 = ((int *) var16)[420];
    var23 = avcDecodeYCbCr (var3, var17);
    var24 = ((int *) var2)[5];
    ((int *) var19)[9] = ((var23 & 0x0FFFFFFF) | (0 & 0x0F));
    ((int *) var19)[10] = var24;
    var25 = ((int *) var16)[414];
    if(!((((var25 + 0xFFFFFFFC) < 3)) == 0))
    {
      var26 = ((int *) var19)[13];
      ((int *) var19)[13] = (var26 | 0xC0000000);
      var27 = ((int *) var16)[431];
      ((int *) var19)[20] = var27;
      var28 = ((int *) var16)[432];
      ((int *) var19)[21] = var28;
    }
    var31 = sub_085E8 (var19);
    ((int *) var2)[5] = 0;
    var32 = var31;
    var33 = ((int *) var19)[13];
    ((int *) var19)[13] = ((var33 & 0x3FFFFFFF) | (0 & 3));
    if(var31 == 0)
    {
      var42 = ((int *) var20)[8];
      ((int *) var1)[0] = var42;
      var43 = ((int *) var16)[414];
      if((((var43 + 0xFFFFFFFD) < 4)) != 0)
      {
        var7 = var32;
        if(!((((var43 + 0xFFFFFFFC) < 3)) == 0))
        {
          var62 = ((int *) var19)[20];
          var63 = ((int *) var19)[21];
          var64 = ((int *) var16)[424];
          var67 = sub_08818 (var64, var19, var62, var63);
          var7 = var67;
          if(!(var67 != 0))
          {
            var68 = ((int *) var16)[424];
            var71 = sub_08A18 (var68, var19);
            var32 = var71;
          label33:
            var7 = var32;
          }
        }
      }
      else
      {
        var44 = 0;
        if(((var31 < var42)) == 0)
          goto label33;
        var45 = arg4;
        var46 = ((int *) var45)[0];
        while (1) {
          var44 = var44 + 1;
          var47 = sp;
          var45 = var45 + 4;
          var7 = 0x806101FE;
          if(var46 == 0)
            break;
          var48 = ((int *) var20)[3];
          ((int *) sp)[0] = (var48 >> 4);
          var49 = ((int *) var20)[2];
          ((int *) sp)[2] = 0;
          ((int *) sp)[1] = (var49 >> 4);
          ((int *) sp)[3] = 0;
          var50 = ((int *) var18)[2];
          var51 = ((int *) var18)[0];
          var52 = ((int *) var18)[4];
          var53 = ((int *) var18)[6];
          var54 = ((int *) var18)[1];
          var55 = ((int *) var18)[3];
          var56 = ((int *) var18)[5];
          var57 = ((int *) var18)[7];
          ((int *) sp)[6] = var50;
          var18 = var18 + 0x2C;
          ((int *) sp)[4] = var51;
          ((int *) sp)[8] = var52;
          ((int *) sp)[10] = var53;
          ((int *) sp)[5] = var54;
          ((int *) sp)[7] = var55;
          ((int *) sp)[9] = var56;
          ((int *) sp)[11] = var57;
          var60 = sceMpegBaseCscAvc (var46, 0, arg3, var47);
          var32 = var60;
          if(var60 != 0)
            goto label33;
          var61 = ((int *) var1)[0];
          if(((var44 < var61)) != 0)
          {
            var46 = ((int *) var45)[0];
            continue;
          }
          else
          {
            var7 = var32;
          }
        }
      }
    }
    else
    {
      var34 = ((int *) var16)[414];
      var7 = var32;
      if(!((((var34 + 0xFFFFFFFC) < 3)) == 0))
      {
        var35 = ((int *) var16)[424];
        var36 = var19;
        var37 = var35 + 0x2C;
        while (1) {
          var38 = ((int *) var36)[0];
          var39 = ((int *) var36)[1];
          var40 = ((int *) var36)[2];
          var41 = ((int *) var36)[3];
          ((int *) var37)[0] = var38;
          var36 = var36 + 0x10;
          var37 = var37 + 0x10;
          ((int *) var37)[1073741821] = var39;
          ((int *) var37)[1073741822] = var40;
          ((int *) var37)[1073741823] = var41;
          if(var36 != (var19 + 0x60))
            continue;
          break;
        }
        goto label33;
      }
    }
  }
  return var7;
}
int mpegAvcDecodeStop (int arg1, int arg2, int arg3, int arg4){
  var1 = arg4;
  var2 = ((int *) arg1)[0];
  var3 = ((int *) var2)[419];
  var4 = ((int *) var2)[421];
  var5 = ((int *) var2)[420];
  if(ret=checkMpegLib(arg1))return ret;
  if(ret=videocodecStop(*arg1[419]))return ret;
  var8 = videocodecStop (*arg1[419]);
	var11 = ((int *) var5)[8];
	*arg4 = var11;
	var12 = ((int *) var2)[414];
	if((((var12 + 0xFFFFFFFD) < 4)) != 0)
	{
		if((((var12 + 0xFFFFFFFC) < 3)) == 0)
		{
			var10 = var9;
		}
		else
		{
			var39 = ((int *) var2)[424];
			var42 = sub_08A18 (var39, var3);
			var43 = ((int *) var2)[424];
			sub_08FE0 (var43);
			var10 = var42;
		}
	}
	else
	{
		var13 = 0;
		if(((var8 < var11)) == 0)
		{
		label22:
			var10 = var9;
		}
		else
		{
			var14 = arg3;
			var15 = ((int *) var14)[0];
			while (1) {
				var13 = var13 + 1;
				var16 = sp;
				var14 = var14 + 4;
				var10 = 0x806101FE;
				if(var15 == 0)
					break;
				var17 = ((int *) var5)[3];
				((int *) sp)[0] = (var17 >> 4);
				var18 = ((int *) var5)[2];
				((int *) sp)[2] = 0;
				((int *) sp)[1] = (var18 >> 4);
				((int *) sp)[3] = 0;
				var19 = ((int *) var4)[0];
				var20 = ((int *) var4)[2];
				var21 = ((int *) var4)[4];
				var22 = ((int *) var4)[6];
				var23 = ((int *) var4)[1];
				var24 = ((int *) var4)[3];
				var25 = ((int *) var4)[5];
				var26 = ((int *) var4)[7];
				((int *) sp)[4] = var19;
				var4 = var4 + 0x2C;
				((int *) sp)[6] = var20;
				((int *) sp)[8] = var21;
				((int *) sp)[10] = var22;
				((int *) sp)[5] = var23;
				((int *) sp)[7] = var24;
				((int *) sp)[9] = var25;
				((int *) sp)[11] = var26;
				var29 = sceMpegBaseCscAvc (var15, 0, arg2, var16);
				var9 = var29;
				if(var29 != 0)
					goto label22;
				if(!(((var13 < *arg4)) != 0))
					goto label22;
				var15 = ((int *) var14)[0];
				continue;
			}
		}
	}
  return var10;
}
int mpegAvcDecodeFlush (int arg1){
  if(ret=checkMpegLib(arg1))return ret;
  if(ret=videocodecStop (*arg1[419]))return ret;
	if(*arg1[414]>=7)return 0;
	ret = sub_08A18 (*arg1[424], *arg1[419]);
	sub_08FE0 (*arg1[424]);
  return ret;
}
int mpegAvcDecodeDetail (int arg1, int arg2){
  return avcDecodeDetail (arg1, 0, arg2);
}
int mpegAvcInitYCbCr (int arg1, int arg2, int arg3, int arg4, int arg5){
  if((ret=checkMpegLib(arg1)))return ret;
	memset (arg5, 0, 0x80);
	if(arg2 == 2){
		arg5[4] = arg2;
		arg5[5] = arg2;
		arg5[6] = arg2;
		arg5[7] = arg2;
		arg5[8] = arg2;
		arg5[9] = arg2;
		arg5[10] = arg2;
		arg5[11] = arg2;
		return 0;
	}
	if(arg2!=1)return 0x806101FE;
	int a,b;
	if((ret=avcInitYCbCr (arg3, arg4,&a,&b)))return ret;
	arg5[4] = arg5 + 0x80;
	var23 = arg5[4] + a;
	var25 = var23 + a;
	var26 = var25 + a>>1;
	var27 = var26 + a>>1;
	var28 = var27 + b;
	var29 = var28 + b;
	arg5[5] = var27;
	arg5[6] = var23;
	arg5[7] = var28;
	arg5[8] = var25;
	arg5[9] = var29;
	arg5[10] = var26;
	arg5[11] = (var29 + (b >> 1));
	return 0;
}
int mpegAvcQueryYCbCrSize (int arg1, int arg2, int arg3, int arg4, int arg5){
  ((int *) arg5)[0] = 0;
  sp = sp + 0xFFFFFFD0;
  ((int *) sp)[7] = s3;
  ((int *) sp)[6] = s2;
  ((int *) sp)[5] = s1;
  var1 = arg2;
  ((int *) sp)[4] = s0;
  ((int *) sp)[8] = ra;
  var2 = arg5;
  var5 = checkMpegLib (arg1);
  var6 = var5;
  var7 = var5;
  if(!(var5 != 0))
  {
    if(var1 == 2)
    {
      ((int *) var2)[0] = 0x80;
    label12:
      var7 = var6;
    }
    else
    {
      var8 = sp;
      var9 = sp + 4;
      var7 = 0x806101FE;
      if(!(var1 != 1))
      {
        var12 = avcInitYCbCr (arg3, arg4, var8, var9);
        var6 = var12;
        var7 = var12;
        if(!(var12 != 0))
        {
          var13 = ((int *) sp)[0];
          var14 = ((int *) sp)[1];
          var15 = var13 + var14;
          ((int *) var2)[0] = (((var15 << 1) + var15) + 0x80);
          goto label12;
        }
      }
    }
  }
  ra = ((int *) sp)[8];
  var16 = ((int *) sp)[7];
  var17 = ((int *) sp)[6];
  var18 = ((int *) sp)[5];
  var19 = ((int *) sp)[4];
  sp = sp + 0x30;
  return var7;
}
int mpegAvcCsc (int arg1, int arg2, int arg3, int arg4, int arg5){
  var1 = arg4;
  var2 = arg5;
  var3 = arg3;
  var4 = arg2;
  var7 = checkMpegLib (arg1);
  ra = ((int *) sp)[21];
  if(!(var7 != 0))
  {
    var8 = ((int *) arg1)[0];
    var9 = ((int *) var4)[1];
    var10 = ((int *) var4)[0];
    var11 = ((int *) var4)[2];
    var12 = ((int *) var4)[3];
    var13 = ((int *) var4)[4];
    ((int *) sp)[1] = var9;
    ((int *) sp)[0] = var10;
    ((int *) sp)[2] = var11;
    ((int *) sp)[3] = var12;
    var14 = ((int *) var8)[421];
    if(var13 == 2)
    {
      var54 = ((int *) var4)[12];
      var55 = *((int *) 0x0000A248);
      var56 = *((int *) 0x0000A24C);
      var57 = *((int *) 0x0000A244);
      var58 = var14 + (var54 * 0x2C);
      var59 = *((int *) 0x0000A250);
      var60 = ((int *) var58)[0];
      var61 = ((int *) var58)[4];
      var62 = ((int *) var58)[3];
      var63 = ((int *) var58)[2];
      var64 = ((int *) var58)[6];
      var65 = ((int *) var58)[1];
      var66 = ((int *) var58)[5];
      var67 = ((int *) var58)[7];
      var27 = var67 + var59;
      ((int *) sp)[4] = (var60 + var57);
      ((int *) sp)[6] = (var63 + var57);
      ((int *) sp)[8] = (var61 + var56);
      ((int *) sp)[10] = (var64 + var56);
      ((int *) sp)[5] = (var65 + var55);
      ((int *) sp)[7] = (var62 + var55);
      ((int *) sp)[9] = (var66 + var59);
    }
    else
    {
      var15 = var4 + 0x10;
      var16 = *((int *) 0x0000A24C);
      var17 = *((int *) 0x0000A248);
      var18 = *((int *) 0x0000A244);
      var19 = ((int *) var15)[1];
      var20 = *((int *) 0x0000A250);
      var21 = ((int *) var15)[2];
      var22 = ((int *) var15)[4];
      var23 = ((int *) var15)[6];
      var24 = ((int *) var15)[3];
      var25 = ((int *) var15)[5];
      var26 = ((int *) var15)[7];
      var27 = var26 + var20;
      ((int *) sp)[4] = (var13 + var18);
      ((int *) sp)[6] = (var21 + var18);
      ((int *) sp)[8] = (var22 + var16);
      ((int *) sp)[10] = (var23 + var16);
      ((int *) sp)[5] = (var19 + var17);
      ((int *) sp)[7] = (var24 + var17);
      ((int *) sp)[9] = (var25 + var20);
    }
    ((int *) sp)[11] = var27;
    var28 = ((int *) var3)[0];
    if((var28 & 0x0F) != 0)
    {
    label28:
      var7 = 0x806101FE;
      ra = ((int *) sp)[21];
    }
    else
    {
      var29 = ((int *) var3)[1];
      if((var29 & 0x0F) != 0)
      {
        goto label28;
      }
      else
      {
        var30 = ((int *) var3)[2];
        if((var30 & 0x0F) != 0)
        {
          goto label28;
        }
        else
        {
          var31 = ((int *) var3)[3];
          if((var31 & 0x0F) != 0)
          {
            goto label28;
          }
          else
          {
            ((int *) sp)[12] = (var28 >> 4);
            ((int *) sp)[13] = (var29 >> 4);
            ((int *) sp)[14] = (var30 >> 4);
            ((int *) sp)[15] = (var31 >> 4);
            var32 = ((int *) var8)[433];
            if(var32 == 1)
            {
              var52 = sp + 0x30;
              var53 = sp;
              ((int *) sp)[3] = 1;
            label23:
              ((int *) sp)[2] = 1;
            label24:
              var7 = sceMpegBaseCscAvcRange (var2, var2, var44, var1, var47);
              ra = ((int *) sp)[21];
            }
            else
            {
              if(((var32 < 2)) != 0)
              {
                if(var32 != 0)
                  goto label28;
                var50 = sp + 0x30;
                var51 = sp;
                ((int *) sp)[2] = 0;
                ((int *) sp)[3] = 0;
                goto label24;
              }
              else
              {
                var33 = ((int *) sp)[4];
                if(var32 == 2)
                {
                  var39 = ((int *) sp)[5];
                  var40 = ((int *) sp)[6];
                  var41 = ((int *) sp)[7];
                  var42 = ((int *) sp)[10];
                  var43 = ((int *) sp)[8];
                  ((int *) sp)[6] = var33;
                  ((int *) sp)[7] = var39;
                  var44 = sp + 0x30;
                  var45 = ((int *) sp)[9];
                  var46 = ((int *) sp)[11];
                  ((int *) sp)[10] = var43;
                  var47 = sp;
                  ((int *) sp)[3] = 1;
                  ((int *) sp)[4] = var40;
                  ((int *) sp)[5] = var41;
                  ((int *) sp)[8] = var42;
                  ((int *) sp)[9] = var46;
                  ((int *) sp)[11] = var45;
                  goto label23;
                }
                else
                {
                  goto label28;
                }
              }
            }
          }
        }
      }
    }
  }
  return var7;
}
int mpeg_0558B075 (int arg1, int arg2, int arg3){
  if((ret=checkMpegLib (arg1)))return ret;
	if(((((arg2 < 1)) | ((arg3 < 1)))))return 0x806101FE;
	if(arg2[4] == 2)return 0x806101FE;
	ret = _0558B075 (arg1, arg2, arg3, 0xFFFFFFFF);
	memcpy(&arg2[13],arg3[13],21-13);
  return ret;
}
int mpegAvcDecodeYCbCr (int arg1, int arg2, int arg3, int arg4){
  if((ret=checkMpegLib (arg1)))return ret;
	*arg1[419][9] = (avcDecodeYCbCr (arg1, arg2[4]) & 0x0FFFFFFF);
	*arg1[419][10] = arg2[5];
	if((*arg1[414] + 0xFFFFFFFC) < 3){
		var21 = *arg1[419][13];
		*arg1[419][13] = (var21 | 0xC0000000);
		var22 = *arg1[431];
		*arg1[419][20] = var22;
		var23 = *arg1[432];
		*arg1[419][21] = var23;
	}
	var26 = sub_085E8 (*arg1[419]);
	((int *) arg2)[5] = 0;
	var27 = var26;
	var28 = *arg1[419][13];
	*arg1[419][13] = ((var28 & 0x3FFFFFFF) | (0 & 3));
	if(var26 == 0)
	{
		var39 = avcDecodeStopYCbCr (arg1, arg3, arg4);
		var40 = *arg1[414];
		var41 = arg1;
		if((((var40 + 0xFFFFFFFC) < 3)) == 0)
		{
		label24:
			var6 = sub_02360 (var41, arg3);
			ra = ((int *) sp)[6];
		}
		else
		{
			var42 = *arg1[419][20];
			var43 = *arg1[419][21];
			var44 = *arg1[424];
			var6 = sub_08818 (var44, *arg1[419], var42, var43);
			ra = ((int *) sp)[6];
			if(!(var6 != 0))
			{
				var47 = *arg1[424];
				var6 = sub_08A18 (var47, *arg1[419]);
				if(var6 != 0)
				{
					ra = ((int *) sp)[6];
				}
				else
				{
					var41 = arg1;
					goto label24;
				}
			}
		}
	}
	else
	{
		var29 = *arg1[414];
		var6 = var27;
		if(!((((var29 + 0xFFFFFFFC) < 3)) == 0))
		{
			var30 = *arg1[424];
			var31 = *arg1[419];
			var32 = var30 + 0x2C;
			while (1) {
				var33 = ((int *) var31)[0];
				var34 = ((int *) var31)[1];
				var35 = ((int *) var31)[2];
				var36 = ((int *) var31)[3];
				((int *) var32)[0] = var33;
				var31 = var31 + 0x10;
				var32 = var32 + 0x10;
				((int *) var32)[1073741821] = var34;
				((int *) var32)[1073741822] = var35;
				((int *) var32)[1073741823] = var36;
				if(var31 != (*arg1[419] + 0x60))
					continue;
				break;
			}
			var6 = var27;
		}
	label31:
		ra = ((int *) sp)[6];
	}
  return var6;
}
int mpegAvcDecodeStopYCbCr (int arg1, int arg2, int arg3){
  if(ret=checkMpegLib(arg1))return ret;
  if(ret=videocodecStop (*arg1[419]))return ret;
	var16 = avcDecodeStopYCbCr (arg1, arg2, arg3);
	if(*arg1[414]>=7)return sub_02360 (arg1, arg2);
	ret = sub_08A18 (*arg1[424], *arg1[419]);
	sub_08FE0 (*arg1[424]);
	if(var16)return var16
  return ret;
}
int mpegAvcCscInfo (int arg1, int arg2, int arg3, int arg4){
  sp = sp + 0xFFFFFFC0;
  ((int *) sp)[11] = s3;
  var1 = arg3;
  ((int *) sp)[10] = s2;
  var2 = arg4;
  ((int *) sp)[9] = s1;
  ((int *) sp)[8] = s0;
  ((int *) sp)[12] = ra;
  var3 = arg2;
  var6 = checkMpegLib (arg1);
  var7 = var6;
  if(!(var6 != 0))
  {
    var8 = ((int *) arg1)[0];
    var7 = 0x806101FE;
    if(!(var1 < 0))
    {
      var9 = ((int *) var3)[19];
      ((int *) var2)[11] = var9;
      var10 = var2 + 0x2C;
      var11 = ((int *) var3)[20];
      ((int *) sp)[0] = (var2 + 0x14);
      ((int *) var2)[12] = var11;
      var12 = ((int *) var3)[21];
      ((int *) sp)[1] = (var2 + 0x20);
      ((int *) var2)[13] = var12;
      var13 = ((int *) var3)[13];
      ((int *) var2)[5] = var13;
      var14 = ((int *) var3)[14];
      ((int *) var2)[6] = var14;
      var15 = ((int *) var3)[15];
      ((int *) var2)[7] = var15;
      var16 = ((int *) var3)[16];
      ((int *) var2)[8] = var16;
      var17 = ((int *) var3)[17];
      ((int *) var2)[9] = var17;
      var18 = ((int *) var3)[18];
      ((int *) var2)[4] = 2;
      ((int *) var2)[10] = var18;
      var19 = ((int *) var10)[1];
      if(var19 == 0x0000138D)
      {
        var51 = ((int *) var10)[2];
        if(var51 != 0x0003A980)
        {
          var20 = ((unsigned char *) var10)[1];
        label13:
          var21 = ((int *) sp)[0];
          if(var20 == 1)
          {
            var49 = ((unsigned char *) var21)[0];
            var22 = (var1 < 3);
            if(!((var49 & 2) == 0))
            {
              var50 = ((unsigned char *) var21)[1];
              if(!(((((var50 + 0xFFFFFFFB) & 0xFF) < 2)) == 0))
              {
              label16:
                ((int *) var2)[4] = 3;
              label17:
                var22 = (var1 < 3);
              }
            }
          }
          else
          goto label17;
        }
        else
        {
          var52 = ((int *) var8)[434];
          var22 = (var1 < 3);
          if(!(var52 != 1))
          {
            goto label16;
          }
        }
      }
      else
      {
        var20 = ((unsigned char *) var10)[1];
        goto label13;
      }
      if(var22 != 0)
      {
        var27 = ((unsigned char *) var10)[0];
        if(var27 == 0)
        {
        label62:
          var34 = 3;
          if(var1 == 2)
          {
          label63:
            ((int *) var2)[0] = var34;
          }
          else
          {
          case 5:
          case 6:
          label64:
            ((int *) var2)[0] = 0;
          }
        }
        else
        {
          var28 = ((int *) var10)[1];
          if(var28 == 0x0000138D)
          {
            var47 = ((int *) var10)[2];
            if(var47 != 0x0003A980)
            {
              var29 = ((unsigned char *) var10)[1];
            label32:
              if(var29 == 0)
                goto label62;
              var30 = ((int *) sp)[0];
              var31 = ((unsigned char *) var30)[0];
              if((var31 & 2) == 0)
              {
                goto label62;
              }
              else
              {
                var32 = ((unsigned char *) var30)[1];
                if(((var32 < 0x07)) == 0)
                {
                  goto label62;
                }
                else
                {
                  var33 = ((int *) ((var32 << 2) + 0x0000A06C))[0];
                  switch () {
                  case 0:
                    goto label62;
                  case 1:
                  case 2:
                    var35 = ((unsigned char *) var30)[0];
                    var36 = 0;
                    if(!((var35 & 1) != 0))
                    {
                      var36 = ((int *) var30)[1];
                    }
                    var37 = ((int *) var30)[2];
                    var38 = ((int *) sp)[1];
                    ((int *) sp)[4] = (var36 + var37);
                    var39 = ((unsigned char *) var38)[0];
                    var40 = 0;
                    if(!((var39 & 1) != 0))
                    {
                      var40 = ((int *) var38)[1];
                    }
                    var41 = ((int *) var38)[2];
                    var42 = var40 + var41;
                    ((int *) sp)[5] = var42;
                    if(var1 == 2)
                    {
                      var34 = 3;
                      goto label63;
                    }
                    else
                    {
                      var43 = ((int *) sp)[4];
                      if(var1 != 0)
                      {
                        if(((var42 < var43)) == 0)
                        {
                          ((int *) var2)[0] = 2;
                        }
                        else
                        {
                          var34 = 1;
                          goto label63;
                        }
                      }
                      else
                      {
                        var44 = ((int *) sp)[4];
                        var1 = (var42 < var44);
                      label58:
                        if(var1 != 0)
                        {
                          ((int *) var2)[0] = 2;
                        }
                        else
                        {
                          var34 = 1;
                          goto label63;
                        }
                      }
                    }
                  case 3:
                    var34 = 3;
                    if(var1 == 2)
                      goto label63;
                    var45 = ((unsigned char *) var30)[2];
                    if(var45 == 0)
                    {
                      ((int *) var2)[0] = 0;
                    }
                    else
                    {
                    }
                    goto label58;
                  case 4:
                    var34 = 3;
                    if(var1 == 2)
                      goto label63;
                    var46 = ((unsigned char *) var30)[2];
                    if(var46 == 0)
                    {
                      ((int *) var2)[0] = 0;
                    }
                    var34 = 1;
                    if(var1 != 0)
                      goto label63;
                    ((int *) var2)[0] = 2;
                    goto label65;
                  goto label64;
                  goto label64;
                  }
                }
              }
            }
            else
            {
              if(var1 != 2)
              {
                ((int *) var2)[0] = 0;
              }
              else
              {
                var48 = ((int *) var8)[434];
                if(var48 == 1)
                {
                  ((int *) var2)[0] = 0;
                  ((int *) var8)[434] = 0;
                }
                else
                {
                  ((int *) var2)[0] = 3;
                  ((int *) var8)[434] = 1;
                }
              }
            }
          }
          else
          {
            var29 = ((unsigned char *) var10)[1];
            goto label32;
          }
        }
      label65:
        var7 = 0;
      }
      else
      {
        var7 = 0;
        ((int *) var2)[0] = 3;
      }
    }
  }
  ra = ((int *) sp)[12];
  var23 = ((int *) sp)[11];
  var24 = ((int *) sp)[10];
  var25 = ((int *) sp)[9];
  var26 = ((int *) sp)[8];
  sp = sp + 0x40;
  return var7;
}
int mpegAvcCscMode (int arg1, int arg2){
  if((ret=checkMpegLib (arg1)))return ret;
	*arg1[433] = *arg2;
  return 0;
}
int mpeg_E49EB257 (int arg1){
  if((ret=checkMpegLib (arg1)))return ret;
	((char *) *arg1)[1740] = 0;
	*arg1[433] = 0;
	*arg1[434] = 0;
  return 0;
}
int avcInitYCbCr (int arg1, int arg2, int arg3, int arg4){
  var1 = arg1 >> 4;
  var2 = arg2 >> 4;
  var3 = 0x806101FE;
  if(!(((arg1 | arg2) & 0x0F) != 0))
  {
    var3 = 0x806101FE;
    if(!((((((var1 + 0xFFFFFFFF) < maxW)) ^ 1) | ((var2 < 1))) != 0))
    {
      if(!(((var2 < maxH)) == 0))
      {
        var4 = var2 << 3;
        var5 = (arg1 & 0xFFFFFFE0) | (0 & 0x1F);
        if((var1 & 1) == 0)
        {
          var6 = ((((arg1 & 0xFFFFFFE0) | (0 & 0x1F)) >> 1) * var4);
          ((int *) arg3)[0] = var6;
          ((int *) arg4)[0] = var6;
        }
        else
        {
          ((int *) arg3)[0] = (((var5 + 0x20) >> 1) * var4);
          ((int *) arg4)[0] = ((var5 >> 1) * var4);
        }
        var3 = 0;
      }
    }
  }
  return var3;
}
int _0558B075 (int arg1, int arg2, int arg3, int arg4){
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[0] = ra;
  var1 = ((int *) arg1)[0];
  var2 = arg2;
  var3 = arg2;
  var4 = ((int *) var1)[420];
  var5 = ((int *) var1)[421];
  if(arg4 == 0xFFFFFFFF)
  {
    var17 = ((int *) arg3)[4];
    if(var17 == 2)
    {
      arg4 = ((int *) arg3)[12];
    label6:
    }
    else
    {
    }
  }
  else
  goto label6;
  var6 = arg4;
  if(arg4 == 0xFFFFFFFF)
  {
    var16 = ((int *) var2)[4];
    var11 = arg3 + 0x10;
    var3 = var2;
    var6 = 0xFFFFFFFF;
    var15 = 0x806101FE;
    if(!(var16 == 2))
    {
      var9 = ((int *) arg3)[0];
      var10 = ((int *) arg3)[1];
    label11:
      var14 = mpegBaseYCrCbCopy (var3, var6, var10, var9, var11);
      var15 = var14;
    }
  }
  else
  {
    var7 = ((int *) var4)[3];
    var8 = ((int *) var4)[2];
    var9 = var7 >> 4;
    var10 = var8 >> 4;
    var11 = var5 + (arg4 * 0x2C);
    goto label11;
  }
  ra = ((int *) sp)[0];
  sp = sp + 0x10;
  return var15;
}
int avcDecodeStopYCbCr (int arg1, int arg2, int arg3){
  sp = sp + 0xFFFFFFE0;
  ((int *) sp)[3] = s3;
  var1 = 0;
  ((int *) sp)[2] = s2;
  var2 = arg3;
  ((int *) sp)[1] = s1;
  var3 = 0;
  ((int *) sp)[4] = ra;
  ((int *) sp)[0] = s0;
  var4 = ((int *) arg1)[0];
  var5 = ((int *) var4)[420];
  var6 = ((int *) var5)[8];
  ((int *) var2)[0] = var6;
  if(!(var6 <= 0))
  {
    var7 = arg2;
    var8 = ((int *) var7)[0];
    while (1) {
      var3 = var3 + 1;
      var7 = var7 + 4;
      var1 = 0x806101FE;
      if(var8 == 0)
        break;
      var11 = _0558B075 (arg1, var8, 0, var3);
      var1 = var11;
      if(var11 != 0)
        break;
      var12 = ((int *) var2)[0];
      if(!(((var3 < var12)) != 0))
        break;
      var8 = ((int *) var7)[0];
      continue;
    }
  }
  ra = ((int *) sp)[4];
  var13 = ((int *) sp)[3];
  var14 = ((int *) sp)[2];
  var15 = ((int *) sp)[1];
  var16 = ((int *) sp)[0];
  sp = sp + 0x20;
  return var1;
}
int sub_02360 (int arg1, int arg2){
  sp = sp + 0xFFFFFFE0;
  ((int *) sp)[5] = s1;
  var1 = sp;
  ((int *) sp)[6] = ra;
  ((int *) sp)[4] = s0;
  var2 = ((int *) arg1)[0];
  var5 = mpegAvcDecodeDetail2 (arg1, var1);
  var6 = var5;
  if(!(var5 != 0))
  {
    var7 = ((int *) sp)[0];
    var8 = 0;
    var9 = ((int *) var7)[4];
    var10 = ((int *) var7)[12];
    var11 = ((int *) var9)[8];
    var12 = ((int *) var7)[11];
    if(!(((var5 < var11)) == 0))
    {
      var13 = arg2;
      var14 = ((int *) var13)[0];
      while (1) {
        var8 = var8 + 1;
        var15 = var14;
        var13 = var13 + 4;
        ((int *) sp)[0] = var14;
        if(var14 == 0)
        {
          var6 = 0x806101FE;
        }
        else
        {
          var16 = ((int *) var9)[9];
          if(var16 == 1)
          {
            ((char *) var2)[1740] = var16;
            var38 = ((unsigned char *) var10)[22];
            if(var38 != var16)
            {
              var17 = ((int *) var2)[435];
            }
            else
            {
              var39 = ((unsigned char *) var10)[44];
              ((char *) var2)[1741] = var39;
              var40 = ((int *) var10)[8];
              ((int *) var2)[436] = var40;
              var41 = ((int *) var10)[9];
              ((int *) var2)[437] = var41;
            label14:
              var17 = ((int *) var2)[435];
            }
          }
          else
          goto label14;
          ((int *) var15)[19] = var17;
          var18 = ((int *) var2)[436];
          ((int *) var15)[20] = var18;
          var19 = ((int *) var2)[437];
          ((int *) var15)[21] = var19;
          var20 = ((int *) var12)[9];
          if(var20 == 0)
          {
            var35 = ((int *) var2)[414];
          }
          else
          {
            var21 = ((int *) var12)[10];
            var22 = var15 + 0x34;
            var23 = var15 + 0x40;
            if(!(var21 == 0))
            {
              var24 = ((unsigned char *) var20)[0];
              ((char *) var15)[52] = var24;
              var25 = ((unsigned char *) var20)[32];
              ((char *) var22)[1] = var25;
              var26 = ((unsigned char *) var20)[36];
              ((char *) var22)[2] = var26;
              var27 = ((int *) var20)[6];
              ((int *) var22)[1] = var27;
              var28 = ((int *) var20)[7];
              var29 = ((int *) var12)[10];
              ((int *) var22)[2] = var28;
              var30 = ((unsigned char *) var29)[0];
              ((char *) var15)[64] = var30;
              var31 = ((unsigned char *) var29)[32];
              ((char *) var23)[1] = var31;
              var32 = ((unsigned char *) var29)[36];
              ((char *) var23)[2] = var32;
              var33 = ((int *) var29)[6];
              ((int *) var23)[1] = var33;
              var34 = ((int *) var29)[7];
              ((int *) var23)[2] = var34;
            }
            var35 = ((int *) var2)[414];
          }
          var12 = var12 + 0x2C;
          if(!((((var35 + 0xFFFFFFFC) < 3)) == 0))
          {
            var9 = var9 + 0x28;
            var10 = var10 + 0x64;
          }
          if(!(((var8 < var11)) != 0))
            break;
          var14 = ((int *) var13)[0];
          continue;
        }
      }
    }
  }
  ra = ((int *) sp)[6];
  var36 = ((int *) sp)[5];
  var37 = ((int *) sp)[4];
  sp = sp + 0x20;
  return var6;
}
int mpegBaseYCrCbCopy (int arg1, int arg2, int arg3, int arg4, int arg5){
  sp = sp + 0xFFFFFFC0;
  ((int *) sp)[13] = ra;
  ((int *) sp)[12] = s0;
  var1 = ((int *) arg1)[4];
  ((int *) arg1)[0] = arg4;
  var2 = arg5;
  var3 = 0;
  ((int *) arg1)[1] = arg3;
  var4 = sp;
  ((int *) arg1)[2] = 0;
  ((int *) arg1)[3] = 0;
  if(var1 == 2)
  {
    ((int *) arg1)[12] = arg2;
  }
  else
  {
    var5 = *((int *) 0x0000A244);
    var6 = *((int *) 0x0000A250);
    var7 = *((int *) 0x0000A24C);
    var8 = *((int *) 0x0000A248);
    var9 = ((int *) var2)[7];
    var10 = ((int *) var2)[0];
    var11 = ((int *) var2)[2];
    var12 = ((int *) var2)[4];
    var13 = ((int *) var2)[6];
    var14 = ((int *) var2)[1];
    var15 = ((int *) var2)[3];
    var16 = ((int *) var2)[5];
    ((int *) sp)[11] = (var9 + var6);
    ((int *) sp)[1] = (arg3 << 4);
    ((int *) sp)[0] = (arg4 << 4);
    ((int *) sp)[4] = (var10 + var5);
    ((int *) sp)[6] = (var11 + var5);
    ((int *) sp)[8] = (var12 + var7);
    ((int *) sp)[10] = (var13 + var7);
    ((int *) sp)[5] = (var14 + var8);
    ((int *) sp)[7] = (var15 + var8);
    ((int *) sp)[9] = (var16 + var6);
    ((int *) sp)[2] = 0;
    ((int *) sp)[3] = 0;
    var19 = sceMpegBaseYCrCbCopy (arg1, var4, 3);
    var3 = var19;
  }
  ra = ((int *) sp)[13];
  var20 = ((int *) sp)[12];
  sp = sp + 0x40;
  return var3;
}
int mpegAtracDecode (int arg1, int arg2, int arg3, int arg4){
  sp = sp + 0xFFFFFFE0;
  ((int *) sp)[3] = s3;
  ((int *) sp)[2] = s2;
  var1 = arg2;
  ((int *) sp)[1] = s1;
  ((int *) sp)[0] = s0;
  ((int *) sp)[4] = ra;
  var4 = checkMpegLib (arg1);
  var5 = var4;
  if(!(var4 != 0))
  {
    var6 = ((int *) arg1)[0];
    var7 = ((int *) var6)[440];
    if(arg4 == 1)
    {
      var16 = ((int *) var1)[4];
      var17 = ((int *) var6)[439];
      var18 = ((int *) var6)[438];
      var21 = audiocodecSetup (var7, var18, var17, (var16 + 2), (var16 + 4));
      var5 = var21;
      if(!(var21 != 0))
      {
        var8 = ((int *) var1)[4];
      label11:
        ((int *) var7)[8] = arg3;
        ((int *) var7)[6] = var8;
        var11 = audiocodecDecode (var7);
        var5 = var11;
      }
    }
    else
    {
      var8 = ((int *) var1)[4];
      goto label11;
    }
  }
  ra = ((int *) sp)[4];
  var12 = ((int *) sp)[3];
  var13 = ((int *) sp)[2];
  var14 = ((int *) sp)[1];
  var15 = ((int *) sp)[0];
  sp = sp + 0x20;
  return var5;
}
int mpegQueryStreamOffset (int arg1, int arg2, int arg3){
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[2] = s2;
  var1 = arg3;
  ((int *) sp)[0] = s0;
  var2 = arg2;
  ((int *) sp)[3] = ra;
  ((int *) sp)[1] = s1;
  var3 = ((int *) arg1)[0];
  var6 = strcmp (var3, "LIBMPEG");
  var7 = 0x806101FE;
  if(var6 == 0)
  {
    var13 = strncmp (var2, "PSMF", 4);
    var7 = 0x806101FE;
    if(var13 != 0)
    {
    label17:
      ((int *) var1)[0] = 0;
    }
    else
    {
      var16 = getPMFversion (var2);
      ((int *) var3)[3] = var16;
      if(var16 < 0)
      {
        var7 = 0x80610002;
        goto label17;
      }
      else
      {
        var19 = be4 ((var2 + 8));
        ((int *) var1)[0] = var19;
        if((var19 & 0x000007FF) != 0)
        {
        label16:
          var7 = 0x806101FE;
          goto label17;
        }
        else
        {
          var7 = 0;
          if(!(var19 != 0))
            goto label16;
        }
      }
    }
  }
  else
  goto label17;
  ra = ((int *) sp)[3];
  var8 = ((int *) sp)[2];
  var9 = ((int *) sp)[1];
  var10 = ((int *) sp)[0];
  sp = sp + 0x10;
  return var7;
}
int checkMpegLib (int arg1){
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[0] = ra;
  var1 = ((int *) arg1)[0];
  var4 = strcmp (var1, "LIBMPEG");
  ra = ((int *) sp)[0];
  sp = sp + 0x10;
  return (!(var4) ? 0 : 0x806101FE);
}
int mpegQueryStreamSize (int arg1, int arg2){
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[0] = s0;
  ((int *) sp)[1] = ra;
  var1 = arg2;
  var4 = be4 ((arg1 + 0x0C));
  ((int *) var1)[0] = var4;
  var5 = 0;
  if(!((var4 & 0x000007FF) == 0))
  {
    ((int *) var1)[0] = 0;
    var5 = 0x806101FE;
  }
  ra = ((int *) sp)[1];
  var6 = ((int *) sp)[0];
  sp = sp + 0x10;
  return var5;
}
int getPMFversion (int arg1){
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[0] = s0;
  var1 = arg1 + 4;
  ((int *) sp)[1] = ra;
  var4 = strncmp (var1, "0012", 4);
  var5 = 0;
  if(var4 != 0)
  {
    var9 = strncmp (var1, "0013", 4);
    var5 = 1;
    if(!(var9 == 0))
    {
      var12 = strncmp (var1, "0014", 4);
      var5 = 2;
      if(!(var12 == 0))
      {
        var15 = strncmp (var1, "0015", 4);
        var5 = (var15) ? 0xFFFFFFFF : 3;
      }
    }
  }
  ra = ((int *) sp)[1];
  var6 = ((int *) sp)[0];
  sp = sp + 0x10;
  return var5;
}
int unRegistStream (int arg1, int arg2, int arg3){
  if(((arg1 & 0xFFFFE000) | (0 & 0x00001FFF)) == 0xBF01E000)
  {
    var18 = (arg1 >> 8) & 0x1F;
    if(arg3 == 1)
    {
      var19 = ((int *) arg2)[6];
      var20 = var18 << 4;
    }
    else
    {
      var19 = ((int *) arg2)[7];
      var20 = ((var18 << 4) + var18) << 2;
    }
    var2 = var19 + var20;
  }
  else
  {
    if(((arg1 & 0xE0000000) | (0 & 0x1FFFFFFF)) == 0xE0000000)
    {
      var15 = (arg1 >> 24) & 0x1F;
      if(arg3 == 1)
      {
        var17 = ((int *) arg2)[6];
        var2 = (var17 + (var15 << 4)) + 0x00000100;
      }
      else
      {
        var16 = ((int *) arg2)[7];
        var2 = (var16 + (((var15 << 4) + var15) << 2)) + 0x00000440;
      }
    }
    else
    {
      var1 = (arg1 & 0xFFF00000) | (0 & 0x000FFFFF);
      if(var1 == 0xBD000000)
      {
        var12 = (arg1 >> 0x10) & 0x000042FF;
        if(arg3 == 1)
        {
          var14 = ((int *) arg2)[6];
          var2 = (var14 + (var12 << 4)) + 0x00000200;
        }
        else
        {
          var13 = ((int *) arg2)[7];
          var2 = (var13 + (((var12 << 4) + var12) << 2)) + 0x00000880;
        }
      }
      else
      {
        if(((arg1 & 0xFFE00000) | (0 & 0x001FFFFF)) == 0xBD800000)
        {
          var9 = (arg1 >> 0x10) & 0x0000427F;
          if(arg3 == 1)
          {
            var11 = ((int *) arg2)[6];
            var2 = (var11 + (var9 << 4)) + 0x00000400;
          }
          else
          {
            var10 = ((int *) arg2)[7];
            var2 = (var10 + (((var9 << 4) + var9) << 2)) + 0x00001100;
          }
        }
        else
        {
          if(var1 == 0xBD100000)
          {
            var6 = (arg1 >> 0x10) & 0x000042EF;
            if(arg3 == 1)
            {
              var8 = ((int *) arg2)[6];
              var2 = (var8 + (var6 << 4)) + 0x00000300;
            }
            else
            {
              var7 = ((int *) arg2)[7];
              var2 = (var7 + (((var6 << 4) + var6) << 2)) + 0x00000CC0;
            }
          }
          else
          {
            var2 = 0xFFFFFFFF;
            if(var1 == 0xBD200000)
            {
              var3 = (arg1 >> 0x10) & 0x000042DF;
              if(arg3 == 1)
              {
                var5 = ((int *) arg2)[6];
                var2 = (var5 + (var3 << 4)) + 0x00000600;
              }
              else
              {
                var4 = ((int *) arg2)[7];
                var2 = (var4 + (((var3 << 4) + var3) << 2)) + 0x00001980;
              }
            }
          }
        }
      }
    }
  }
  return var2;
}
void getAu (int arg1, int arg2, int arg3, int arg4, int arg5){
  var1 = ((int *) arg1)[1];
  ((int *) arg5)[0] = 0;
  var2 = 0x806101FE;
  if(!(var1 == 0xFFFFFFFF))
  {
    var3 = ((int *) arg1)[3];
    var2 = 0;
    if(!(((arg2 < var3)) == 0))
    {
      var4 = var1;
      if(!(arg2 <= 0))
      {
        var5 = arg2;
        while (1) {
          var5 = var5 + 0xFFFFFFFF;
          var4 = ((int *) var4)[0];
          if(var5 != 0)
            continue;
          break;
        }
      }
      var6 = MIN ((var3 - arg2), arg3);
      var7 = 0;
      if(!(var6 <= 0))
      {
        var8 = 0;
        while (1) {
          var9 = var8 + arg4;
          var10 = var4 + 8;
          while (1) {
            var11 = ((int *) var10)[0];
            var12 = ((int *) var10)[1];
            var13 = ((int *) var10)[2];
            var14 = ((int *) var10)[3];
            ((int *) var9)[0] = var11;
            var10 = var10 + 0x10;
            var9 = var9 + 0x10;
            ((int *) var9)[1073741821] = var12;
            ((int *) var9)[1073741822] = var13;
            ((int *) var9)[1073741823] = var14;
            if(var10 != (var4 + 0x28))
              continue;
            break;
          }
          var15 = ((int *) var10)[0];
          var16 = ((int *) var10)[1];
          var17 = ((int *) var10)[2];
          ((int *) var9)[0] = var15;
          ((int *) var9)[1] = var16;
          ((int *) var9)[2] = var17;
          var7 = var7 + 1;
          var4 = ((int *) var4)[0];
          var8 = var8 + 0x2C;
          if(((var7 < var6)) != 0)
            continue;
          break;
        }
      }
      ((int *) arg5)[0] = var6;
      var2 = 0;
    }
  }
  return;
}
void sub_02AEC (int arg1, int arg2, int arg3){
  var1 = ((int *) arg1)[1];
  ((int *) arg3)[0] = 0;
  var2 = 0x806101FE;
  if(!(var1 == 0xFFFFFFFF))
  {
    var3 = ((int *) arg1)[3];
    var4 = var1;
    var5 = MIN (var3, arg2);
    var6 = var3;
    var7 = var5;
    if(!(var5 <= 0))
    {
      while (1) {
        var8 = ((int *) var4)[0];
        var9 = var6 + 0xFFFFFFFF;
        var7 = var7 + 0xFFFFFFFF;
        ((int *) var4)[0] = 0xFFFFFFFF;
        var6 = var9;
        ((int *) var4)[1] = 0xFFFFFFFF;
        var4 = var8;
        ((int *) arg1)[3] = var9;
        if(var7 != 0)
          continue;
        break;
      }
    }
    ((int *) arg3)[0] = var5;
    var10 = ((int *) arg1)[3];
    ((int *) arg1)[1] = var4;
    if(!(var10 != 0))
    {
      ((int *) arg1)[1] = 0xFFFFFFFF;
      ((int *) arg1)[0] = 0xFFFFFFFF;
    }
    var2 = 0;
  }
  return;
}
int ringbufferPutB (int arg1, int arg2, int arg3, int arg4){
  sp = sp + 0xFFFFFF60;
  ((int *) sp)[34] = s6;
  var1 = arg4;
  ((int *) sp)[29] = s1;
  var2 = arg2;
  ((int *) sp)[28] = s0;
  ((int *) sp)[37] = ra;
  ((int *) sp)[36] = fp;
  ((int *) sp)[35] = s7;
  ((int *) sp)[33] = s5;
  ((int *) sp)[32] = s4;
  ((int *) sp)[31] = s3;
  ((int *) sp)[30] = s2;
  var3 = ((int *) arg1)[0];
  var6 = checkMpegLib (arg1);
  var7 = var6;
  if(var6 != 0)
  {
  label64:
    ra = ((int *) sp)[37];
  }
  else
  {
    ((int *) var1)[0] = 0;
    var8 = ((int *) var2)[4];
    var7 = 0x806101FE;
    if(var8 != 0x00000800)
      goto label64;
    var11 = ringbufferPutBA (var2);
    var12 = ((int *) var2)[4];
    var13 = ((MIN (arg3, var11)) * var12);
    var7 = 0;
    if(!(var13 != 0))
      goto label64;
    var23 = ((int *) var3)[411];
    var24 = var13 << 3;
    var25 = sp;
    waitSema ();
    var28 = ((int *) var2)[4];
    var29 = ((int *) var2)[1];
    var30 = ((int *) var2)[0];
    var31 = ((int *) var2)[5];
    var32 = sp;
    ((int *) sp)[0] = 0;
    var33 = var31 + (var29 * var28);
    ((int *) sp)[3] = var33;
    var34 = (var30 * var28);
    ((int *) sp)[6] = (var31 + var34);
    ((int *) sp)[7] = var34;
    ((int *) sp)[2] = var33;
    ((int *) sp)[4] = 0;
    ((int *) sp)[1] = 0;
    ((int *) sp)[5] = var31;
    ringStuff (var32, 0);
    var37 = ((int *) sp)[0];
    var38 = var25;
    if(var37 == 0x000001BA)
    {
    label21:
      var88 = sp + 0x20;
      ringbufferPutBB (var38, var88);
      var37 = ((int *) var25)[0];
      goto label14;
    }
  label14:
    var39 = ((int *) var25)[1];
    var40 = 0;
    var41 = 0;
    while (1) {
      if((var37 >> 8) != 1)
        break;
      if(var37 == 0x000001BA)
        break;
      if(var37 == 0x000001B9)
        break;
      var42 = sp + 0x20;
      if(((var39 < var24)) == 0)
        break;
      var43 = var42 + 0x18;
      var46 = ringbufferPutBC (var25, var43);
      if(var46 < 0)
        goto label49;
      var39 = ((int *) var25)[1];
      if(((var24 < var39)) != 0)
      {
        var37 = ((int *) var25)[0];
      label63:
        var40 = var40 + 1;
        var41 = var41 + 0x34;
        continue;
      }
      else
      {
        var47 = ((int *) sp)[14];
        var50 = unRegistStream (var47, var3, 1);
        var51 = var50;
        if(var50 == 0xFFFFFFFF)
        {
        label60:
          var74 = ((int *) var2)[4];
          if(var74 == 0)
          {
            __asm__ ("break      0x00007;");
          }
          ((int *) var1)[0] = ((var39 >> 3) / var74);
          var37 = ((int *) var25)[0];
          goto label63;
        }
        else
        {
          var52 = ((int *) var50)[2];
          if(var52 == 0xFFFFFFFF)
            goto label60;
          var53 = ((int *) var2)[4];
          var54 = ((int *) var1)[0];
          if(var53 == 0)
          {
            __asm__ ("break      0x00007;");
          }
          var55 = ((int *) var2)[1];
          var56 = ((int *) var2)[0];
          var57 = ((int *) var3)[5];
          var58 = var55 + ((var54 * var53) / var53);
          if(((var40 < 2)) == 0)
            goto label49;
          var59 = ((int *) var51)[0];
          var60 = (var57 + ((!(((var58 < var56))) ? (var58 - var56) : var58) * 0x68)) + var41;
          ((int *) var60)[0] = 0xFFFFFFFF;
          ((int *) var60)[1] = var59;
          var61 = ((int *) var51)[0];
          if(var61 != 0xFFFFFFFF)
          {
            ((int *) var61)[0] = var60;
          }
          ((int *) var51)[0] = var60;
          var62 = var43;
          var63 = sp + 0x20;
          var64 = var60 + 8;
          while (1) {
            var65 = ((int *) var62)[0];
            var66 = ((int *) var62)[1];
            var67 = ((int *) var62)[2];
            var68 = ((int *) var62)[3];
            ((int *) var64)[0] = var65;
            var62 = var62 + 0x10;
            var64 = var64 + 0x10;
            ((int *) var64)[1073741821] = var66;
            ((int *) var64)[1073741822] = var67;
            ((int *) var64)[1073741823] = var68;
            if(var62 != (var63 + 0x38))
              continue;
            break;
          }
          var69 = ((int *) var62)[0];
          var70 = ((int *) var62)[1];
          var71 = ((int *) var62)[2];
          ((int *) var64)[0] = var69;
          ((int *) var64)[1] = var70;
          ((int *) var64)[2] = var71;
          var72 = ((int *) var51)[1];
          if(var72 == 0xFFFFFFFF)
          {
            var75 = ((int *) var51)[0];
            ((int *) var51)[1] = var75;
          }
          var73 = ((int *) var51)[3];
          ((int *) var51)[3] = (var73 + 1);
          var39 = ((int *) var25)[1];
          goto label60;
        }
      }
      goto label65;
    }
    if(((var39 < var24)) != 0)
    {
      var38 = var25;
      if(var37 == 0x000001BA)
        goto label21;
      var83 = ((int *) var3)[411];
      signalSema ();
      var86 = ((int *) var25)[1];
      var87 = ((int *) var2)[4];
      var7 = 0x80618007;
      if(var87 == 0)
      {
        __asm__ ("break      0x00007;");
      }
      if(((var86 >> 3) % var87) == 0)
      {
        var7 = 0;
        goto label64;
      }
      else
      {
        ra = ((int *) sp)[37];
      }
    }
    else
    {
      var79 = ((int *) var2)[4];
      if(var79 == 0)
      {
        __asm__ ("break      0x00007;");
      }
      if(((var39 >> 3) % var79) != 0)
      {
      label49:
        var76 = ((int *) var3)[411];
        signalSema ();
        var7 = 0x80618007;
      }
      else
      {
        var80 = ((int *) var3)[411];
        signalSema ();
        var7 = 0;
      }
      goto label64;
    }
  }
label65:
  var14 = ((int *) sp)[36];
  var15 = ((int *) sp)[35];
  var16 = ((int *) sp)[34];
  var17 = ((int *) sp)[33];
  var18 = ((int *) sp)[32];
  var19 = ((int *) sp)[31];
  var20 = ((int *) sp)[30];
  var21 = ((int *) sp)[29];
  var22 = ((int *) sp)[28];
  sp = sp + 0xA0;
  return var7;
}
void ringStuff (int arg1, int arg2){
  var1 = arg1;
  var2 = arg2;
  while (1) {
    if(((var2 < 0x19)) != 0)
      break;
    var3 = ((int *) var1)[4];
    var4 = ((int *) var1)[0];
    var5 = var3 + 0xFFFFFFE8;
    ((int *) var1)[0] = (var4 << 0x18);
    ((int *) var1)[4] = var5;
    if(!(((var5 < 0x19)) == 0))
    {
      var6 = ((int *) var1)[6];
      while (1) {
        var7 = ((int *) var1)[3];
        var8 = ((int *) var1)[4];
        var9 = ((int *) var1)[0];
        var10 = ((unsigned char *) var7)[0];
        var11 = var7 + 1;
        var12 = var8 + 8;
        ((int *) var1)[0] = (var9 | (var10 << (0x18 - var8)));
        ((int *) var1)[3] = var11;
        if(!(((var11 < var6)) != 0))
        {
          var13 = ((int *) var1)[5];
          ((int *) var1)[3] = var13;
        }
        ((int *) var1)[4] = var12;
        if(((var12 < 0x19)) != 0)
          continue;
        break;
      }
    }
    var14 = ((int *) var1)[1];
    var2 = var2 + 0xFFFFFFE8;
    ((int *) var1)[1] = (var14 + 0x18);
    continue;
  }
  var15 = ((int *) var1)[4];
  var16 = ((int *) var1)[0];
  var17 = var15 - var2;
  ((int *) var1)[0] = (var16 << var2);
  ((int *) var1)[4] = var17;
  if(!(((var17 < 0x19)) == 0))
  {
    var18 = ((int *) var1)[6];
    while (1) {
      var19 = ((int *) var1)[3];
      var20 = ((int *) var1)[4];
      var21 = ((int *) var1)[0];
      var22 = ((unsigned char *) var19)[0];
      var23 = var19 + 1;
      var24 = var20 + 8;
      ((int *) var1)[0] = (var21 | (var22 << (0x18 - var20)));
      ((int *) var1)[3] = var23;
      if(!(((var23 < var18)) != 0))
      {
        var25 = ((int *) var1)[5];
        ((int *) var1)[3] = var25;
      }
      ((int *) var1)[4] = var24;
      if(((var24 < 0x19)) != 0)
        continue;
      break;
    }
  }
  var26 = ((int *) var1)[1];
  ((int *) var1)[1] = (var26 + var2);
  return;
}
void ringbufferPutBB (int arg1, int arg2){
  sp = sp + 0xFFFFFFE0;
  ((int *) sp)[6] = s6;
  var1 = arg2;
  ((int *) sp)[4] = s4;
  var2 = arg1;
  ((int *) sp)[7] = ra;
  ((int *) sp)[5] = s5;
  ((int *) sp)[3] = s3;
  ((int *) sp)[2] = s2;
  ((int *) sp)[1] = s1;
  ((int *) sp)[0] = s0;
  ringStuff (arg1, 0x22);
  var5 = ((int *) var2)[0];
  ringStuff (var2, 3);
  ringStuff (var2, 1);
  var10 = ((int *) var2)[0];
  ringStuff (var2, 0x0F);
  ringStuff (var2, 1);
  var15 = ((int *) var2)[0];
  ringStuff (var2, 0x0F);
  ringStuff (var2, 1);
  var20 = ((int *) var2)[0];
  ringStuff (var2, 0x09);
  ((int *) var1)[0] = (var20 >> 0x17);
  ringStuff (var2, 0x1E);
  var25 = ((int *) var2)[0];
  var26 = var25 >> 0x1D;
  ringStuff (var2, 3);
  ((int *) var1)[1] = ((((var5 >> 0x1D) << 0x1E) | ((var10 >> 0x11) << 0x0F)) | (var15 >> 0x11));
  var29 = 0;
  ((int *) var1)[2] = (var5 >> 0x1F);
  if(var26 != 0)
  {
    var47 = var2;
    while (1) {
      var29 = var29 + 1;
      ringStuff (var47, 8);
      var47 = var2;
      if(((var29 < var26)) != 0)
        continue;
      break;
    }
    var30 = ((int *) var2)[0];
  }
  else
  {
    var30 = ((int *) var2)[0];
  }
  if(var30 == 0x000001BB)
  {
    ((int *) var1)[3] = 1;
    ringStuff (var2, 0x38);
    ringStuff (var2, 0x28);
    var42 = ((int *) var2)[0];
    ra = ((int *) sp)[7];
    if(!((var42 >> 0x1F) != 1))
    {
      var43 = var2;
      while (1) {
        ringStuff (var43, 0x18);
        var46 = ((int *) var2)[0];
        var43 = var2;
        if((var46 >> 0x1F) == 1)
          continue;
        break;
      }
      ra = ((int *) sp)[7];
    }
  }
  else
  {
    ((int *) var1)[3] = 0;
    ra = ((int *) sp)[7];
  }
  var31 = ((int *) sp)[6];
  var32 = ((int *) sp)[5];
  var33 = ((int *) sp)[4];
  var34 = ((int *) sp)[3];
  var35 = ((int *) sp)[2];
  var36 = ((int *) sp)[1];
  var37 = ((int *) sp)[0];
  sp = sp + 0x20;
  return;
}
int ringbufferPutBC (int arg1, int arg2){
  sp = sp + 0xFFFFFFC0;
  ((int *) sp)[9] = s5;
  var1 = arg2;
  ((int *) sp)[8] = s4;
  ((int *) sp)[13] = ra;
  ((int *) sp)[12] = fp;
  ((int *) sp)[11] = s7;
  ((int *) sp)[10] = s6;
  ((int *) sp)[7] = s3;
  ((int *) sp)[6] = s2;
  ((int *) sp)[5] = s1;
  ((int *) sp)[4] = s0;
  var2 = ((int *) arg1)[1];
  var3 = ((int *) arg1)[2];
  var4 = ((int *) arg1)[6];
  var5 = var3 + (var2 >> 3);
  var6 = arg1;
  if(!(((var5 < var4)) != 0))
  {
    var7 = ((int *) arg1)[7];
    var5 = var5 - var7;
  }
  ((int *) var1)[9] = var5;
  ringStuff (arg1, 0x18);
  var10 = ((unsigned char *) var6)[3];
  ringStuff (var6, 8);
  ((int *) var1)[0] = (var10 << 0x18);
  var13 = ((unsigned short *) var6)[1];
  ringStuff (var6, 0x10);
  var16 = ((int *) var1)[0];
  ((int *) var1)[1] = var13;
  ((int *) var1)[4] = 0xFFFFFFFF;
  ((int *) var1)[5] = 0xFFFFFFFF;
  ((int *) var1)[3] = 0xFFFFFFFF;
  ((int *) var1)[6] = 0xFFFFFFFF;
  if((((0 < (var16 ^ 0xBC000000))) & ((0 < (var16 ^ 0xBE000000)))) == 0)
  {
  label17:
    if(((((var16 ^ 0xBC000000) < 1)) | (((var16 ^ 0xBF000000) < 1))) != 0)
    {
    label23:
      var165 = ((int *) var1)[1];
      if(var16 == 0xBF000000)
      {
        var166 = ((int *) var6)[1];
        var167 = ((int *) var6)[2];
        var168 = ((int *) var6)[6];
        var169 = var167 + (var166 >> 3);
        if(((var169 < var168)) != 0)
        {
          ((int *) var1)[8] = var165;
        }
        else
        {
          var170 = ((int *) var6)[7];
          var169 = var169 - var170;
          ((int *) var1)[8] = var165;
        }
        var171 = ((int *) var6)[0];
        ((int *) var1)[7] = var169;
        var165 = var165 + 0xFFFFFFFD;
        ringStuff (var6, 0x18);
        var174 = ((int *) var1)[0];
        ((int *) var1)[0] = (var174 | (var171 >> 8));
      }
      if(var165 == 0)
      {
        var65 = 1;
      }
      else
      {
        var66 = ((int *) var6)[1];
        var67 = var165 << 3;
      label155:
        var68 = ((int *) var6)[2];
        var69 = var66 + var67;
        var70 = ((int *) var6)[6];
        var71 = var68 + (var69 >> 3);
        ((int *) var6)[0] = 0;
        ((int *) var6)[4] = 0;
        ((int *) var6)[1] = var69;
        ((int *) var6)[3] = var71;
        if(!(((var71 < var70)) != 0))
        {
          var72 = ((int *) var6)[7];
          ((int *) var6)[3] = (var71 - var72);
        }
        ringStuff (var6, 0);
        var65 = 1;
      }
    }
    else
    {
      if(var16 == 0xF0000000)
        goto label23;
      if(var16 == 0xF1000000)
        goto label23;
      if(var16 == 0xFF000000)
        goto label23;
      if(var16 == 0xF2000000)
        goto label23;
      if(var16 == 0xF8000000)
        goto label23;
      var65 = 1;
      if(!(var16 != 0xBE000000))
      {
        var164 = ((int *) var1)[1];
        if(var164 == 0)
        {
          var65 = 1;
        }
        else
        {
          var66 = ((int *) var6)[1];
          var67 = var164 << 3;
          goto label155;
        }
      }
    }
  }
  else
  {
    if(var16 == 0xBF000000)
      goto label17;
    if(var16 == 0xF0000000)
      goto label17;
    if(var16 == 0xF1000000)
      goto label17;
    if(var16 == 0xFF000000)
      goto label17;
    if(var16 == 0xF2000000)
      goto label17;
    if(var16 == 0xF8000000)
      goto label17;
    ringStuff (var6, 2);
    var19 = ((int *) var6)[0];
    ringStuff (var6, 2);
    ((int *) var1)[2] = (var19 >> 0x1E);
    ringStuff (var6, 4);
    var24 = ((int *) var6)[0];
    var25 = var24 >> 0x1E;
    ringStuff (var6, 2);
    var28 = ((int *) var6)[0];
    ((int *) sp)[1] = (var28 >> 0x1F);
    ringStuff (var6, 1);
    var31 = ((int *) var6)[0];
    var32 = var31 >> 0x1C;
    ringStuff (var6, 4);
    var35 = ((int *) var6)[0];
    var36 = var35 >> 0x1F;
    ringStuff (var6, 1);
    var39 = ((unsigned char *) var6)[3];
    ((int *) sp)[2] = var39;
    ringStuff (var6, 8);
    var42 = ((int *) var6)[1];
    ((int *) sp)[0] = var42;
    if((var25 & 2) != 0)
    {
      ringStuff (var6, 4);
      var149 = ((int *) var6)[0];
      ringStuff (var6, 3);
      ringStuff (var6, 1);
      var154 = ((int *) var6)[0];
      ringStuff (var6, 0x0F);
      ringStuff (var6, 1);
      var159 = ((int *) var6)[0];
      ringStuff (var6, 0x0F);
      ringStuff (var6, 1);
      ((int *) var1)[4] = ((((var149 >> 0x1D) << 0x1E) | ((var154 >> 0x11) << 0x0F)) | (var159 >> 0x11));
      ((int *) var1)[3] = (var149 >> 0x1F);
    }
    if(var25 == 3)
    {
      ringStuff (var6, 4);
      var132 = ((int *) var6)[0];
      ringStuff (var6, 3);
      ringStuff (var6, 1);
      var137 = ((int *) var6)[0];
      ringStuff (var6, 0x0F);
      ringStuff (var6, 1);
      var142 = ((int *) var6)[0];
      ringStuff (var6, 0x0F);
      ringStuff (var6, 1);
      ((int *) var1)[6] = ((((var132 >> 0x1D) << 0x1E) | ((var137 >> 0x11) << 0x0F)) | (var142 >> 0x11));
      ((int *) var1)[5] = (var132 >> 0x1F);
    }
    else
    {
    }
    var43 = ((int *) sp)[1];
    if(var43 == 1)
    {
      ringStuff (var6, 0x30);
    }
    if(var32 != 0)
    {
      var125 = ((unsigned char *) (var32 + 0x0000A088))[0];
      ringStuff (var6, var125);
    }
    if(var36 == 1)
    {
      var88 = ((int *) var6)[0];
      ringStuff (var6, 1);
      var91 = ((int *) var6)[0];
      ringStuff (var6, 1);
      var94 = ((int *) var6)[0];
      ringStuff (var6, 1);
      var97 = ((int *) var6)[0];
      ringStuff (var6, 1);
      ringStuff (var6, 3);
      var102 = ((int *) var6)[0];
      ringStuff (var6, 1);
      if((var88 >> 0x1F) == var36)
      {
        ringStuff (var6, 0x30);
        ringStuff (var6, 0x30);
        ringStuff (var6, 0x20);
      }
      else
      {
      }
      var65 = 0x80618007;
      if(!((var91 >> 0x1F) == 1))
      {
        if((var94 >> 0x1F) == 1)
        {
          ringStuff (var6, 0x10);
        }
        if((var97 >> 0x1F) == 1)
        {
          ringStuff (var6, 0x10);
        }
        if((var102 >> 0x1F) != var36)
        {
          var44 = ((int *) var6)[1];
        }
        else
        {
          ringStuff (var6, 1);
          var107 = ((int *) var6)[0];
          var108 = var107 >> 0x19;
          ringStuff (var6, 0x07);
          var111 = 0;
          if(var108 == 0)
          {
          label139:
            var44 = ((int *) var6)[1];
          }
          else
          {
            var112 = var6;
            while (1) {
              var111 = var111 + 1;
              ringStuff (var112, 8);
              if(!(((var111 < var108)) != 0))
                break;
              var112 = var6;
              continue;
            }
            var44 = ((int *) var6)[1];
          }
        }
        var45 = ((int *) sp)[0];
        var46 = ((int *) sp)[2];
        var47 = var46 - ((var44 - var45) >> 3);
        if(var47 == 0)
        {
          var55 = ((int *) var1)[1];
        }
        else
        {
          var48 = ((int *) var6)[2];
          var49 = var44 + (var47 << 3);
          var50 = ((int *) var6)[6];
          var51 = var48 + (var49 >> 3);
          ((int *) var6)[0] = 0;
          ((int *) var6)[4] = 0;
          ((int *) var6)[1] = var49;
          ((int *) var6)[3] = var51;
          if(!(((var51 < var50)) != 0))
          {
            var52 = ((int *) var6)[7];
            ((int *) var6)[3] = (var51 - var52);
          }
          ringStuff (var6, 0);
          var55 = ((int *) var1)[1];
        }
        var56 = ((int *) sp)[2];
        var57 = ((int *) var6)[2];
        var58 = ((int *) var6)[6];
        var59 = var55 - var56;
        var60 = var59 + 0xFFFFFFFD;
        ((int *) var1)[8] = var60;
        var61 = ((int *) var6)[1];
        var62 = var57 + (var61 >> 3);
        var63 = ((int *) var1)[0];
        if(!(((var62 < var58)) != 0))
        {
          var64 = ((int *) var6)[7];
          var62 = var62 - var64;
        }
        ((int *) var1)[7] = var62;
        if(var63 == 0xBD000000)
        {
          var84 = ((int *) var6)[0];
          ringStuff (var6, 0x18);
          var87 = ((int *) var1)[0];
          var60 = var59 + 0xFFFFFFFA;
          ((int *) var1)[0] = (var87 | (var84 >> 8));
        }
        var65 = 1;
        if(!(var60 == 0))
        {
          var66 = ((int *) var6)[1];
          var67 = var60 << 3;
          goto label155;
        }
      }
    }
    else
    goto label139;
  }
  ra = ((int *) sp)[13];
  var75 = ((int *) sp)[12];
  var76 = ((int *) sp)[11];
  var77 = ((int *) sp)[10];
  var78 = ((int *) sp)[9];
  var79 = ((int *) sp)[8];
  var80 = ((int *) sp)[7];
  var81 = ((int *) sp)[6];
  var82 = ((int *) sp)[5];
  var83 = ((int *) sp)[4];
  sp = sp + 0x40;
  return var65;
}
int mpegRingbufferPut (int arg1, int arg2, int arg3){
  if((ret=ringbufferPutA (arg1, arg2, arg3))< 0)return ret;
	ret = ringbufferPutB (arg1[10], arg1, var4, sp);
	ret2 = ringbufferPutC (arg1, var4);
	return ret?ret:ret2;
}
int ringbufferPutA (int arg1, int arg2, int arg3){
  sp = sp + 0xFFFFFFE0;
  ((int *) sp)[2] = s2;
  var1 = arg1;
  ((int *) sp)[1] = s1;
  ((int *) sp)[0] = s0;
  ((int *) sp)[7] = ra;
  ((int *) sp)[6] = s6;
  ((int *) sp)[5] = s5;
  ((int *) sp)[4] = s4;
  ((int *) sp)[3] = s3;
  var2 = ((int *) arg1)[10];
  var3 = ((int *) var2)[0];
  var6 = checkMpegLib (var2);
  var7 = var6;
  if(var6 == 0)
  {
    var15 = ((int *) var3)[411];
    var16 = MIN (arg2, arg3);
    var17 = ((int *) var1)[6];
    var18 = 0;
    waitSema ();
    if(var16 <= 0)
    {
    label30:
      var45 = ((int *) var3)[411];
      signalSema ();
      var7 = var18;
    }
    else
    {
      var21 = ((int *) var1)[0];
      var22 = ((int *) var1)[2];
      while (1) {
        if(var17 == 0)
        {
          var51 = ((int *) var3)[411];
          signalSema ();
          var7 = 0x80610103;
        }
        else
        {
          var23 = ((int *) var3)[411];
          signalSema ();
          var26 = ((int *) var1)[11];
          var27 = gp;
          gp = var26;
          var28 = ((int *) var1)[4];
          var29 = ((int *) var1)[2];
          var30 = ((int *) var1)[5];
          var31 = ((int *) var1)[7];
          var34 var35 = (*var17) ((var30 + (var29 * var28)), ((((var21 < (var22 + var16)))) ? (var21 - var22) : var16), var31);
          var36 = var34;
          var37 = gp;
          gp = var27;
          var38 = ((int *) var3)[411];
          waitSema ();
          if(var36 < 0)
          {
            if(var18 <= 0)
            {
              var48 = ((int *) var3)[411];
              signalSema ();
              var7 = var36;
            }
            else
            {
              var36 = 0;
            label25:
              var41 = ((int *) var1)[2];
              var42 = ((int *) var1)[0];
              var18 = var18 + var36;
              var43 = var41 + var36;
              var16 = var16 - var36;
              var21 = var42;
              ((int *) var1)[2] = var43;
              if(var43 == var42)
              {
                ((int *) var1)[2] = 0;
              }
              var44 = ((int *) var1)[3];
              ((int *) var1)[3] = (var44 + var36);
              if(var36 == 0)
                break;
              if(!(var16 > 0))
                break;
              var22 = ((int *) var1)[2];
              continue;
            }
          }
          else
          goto label25;
        }
        goto label33;
      }
      goto label30;
    }
  }
label33:
  ra = ((int *) sp)[7];
  var8 = ((int *) sp)[6];
  var9 = ((int *) sp)[5];
  var10 = ((int *) sp)[4];
  var11 = ((int *) sp)[3];
  var12 = ((int *) sp)[2];
  var13 = ((int *) sp)[1];
  var14 = ((int *) sp)[0];
  sp = sp + 0x20;
  return var7;
}
int mpegRingbufferAvailableSize (int arg1){
  sp = sp + 0xFFFFFFD0;
  ((int *) sp)[6] = s2;
  var1 = arg1;
  ((int *) sp)[8] = ra;
  ((int *) sp)[7] = s3;
  ((int *) sp)[5] = s1;
  ((int *) sp)[4] = s0;
  var2 = ((int *) arg1)[10];
  var3 = ((int *) var2)[0];
  var6 = checkMpegLib (var2);
  if(var6 == 0)
  {
    var11 = ((int *) var3)[411];
    waitSema ();
    var14 = ((int *) var1)[3];
    var15 = ((int *) var1)[0];
    var16 = 0;
    if(var14 == var15)
    {
      var36 = ((int *) var3)[411];
      signalSema ();
      var6 = 0;
    }
    else
    {
      var17 = ((int *) var1)[1];
      ((int *) sp)[0] = var17;
      var18 = ((int *) var3)[6];
      while (1) {
        var19 = var18 + (var16 << 4);
        var20 = ((int *) var19)[2];
        var16 = var16 + 1;
        if(var20 == 0xFFFFFFFF)
        {
        label18:
          var23 = (var16 < 0x70);
        label19:
          if(var23 != 0)
          {
            var18 = ((int *) var3)[6];
            continue;
          }
          else
          {
            var24 = ((int *) sp)[0];
          }
        }
        else
        {
          var21 = ((int *) var19)[1];
          var22 = sp;
          if(!(var21 != 0xFFFFFFFF))
            goto label18;
          var33 = ((int *) var21)[9];
          ringbufferAvailableSize (var1, var22, var33);
          var24 = ((int *) sp)[0];
          var23 = (var16 < 0x70);
          if(var24 != 0xFFFFFFFF)
            goto label19;
          break;
        }
        goto label22;
      }
    label22:
      if(var24 == 0xFFFFFFFF)
      {
        var28 = ((int *) var1)[3];
        var27 = ((int *) var1)[0];
        var29 = var27 - var28;
      }
      else
      {
        var25 = ((int *) var1)[2];
        var26 = ((int *) var1)[1];
        var27 = ((int *) var1)[0];
        if(((var25 < var26)) != 0)
        {
        label28:
          var28 = ((int *) var1)[3];
          var29 = var26 - var24;
        }
        else
        {
          if(!(((var26 < var24)) != 0))
            goto label28;
          var28 = ((int *) var1)[3];
          var29 = (var27 - var24) + var26;
        }
      }
      var30 = ((int *) var3)[411];
      signalSema ();
      var6 = ((var27 - var28) - var29);
    }
  }
  ra = ((int *) sp)[8];
  var7 = ((int *) sp)[7];
  var8 = ((int *) sp)[6];
  var9 = ((int *) sp)[5];
  var10 = ((int *) sp)[4];
  sp = sp + 0x30;
  return var6;
}
int mpeg_C2F02CDD (int arg1, int arg2, int arg3, int arg4){
  sp = sp + 0xFFFFFFD0;
  ((int *) sp)[7] = s7;
  var1 = arg4;
  ((int *) sp)[3] = s3;
  ((int *) sp)[2] = s2;
  ((int *) sp)[0] = s0;
  ((int *) sp)[8] = ra;
  ((int *) sp)[6] = s6;
  ((int *) sp)[5] = s5;
  ((int *) sp)[4] = s4;
  ((int *) sp)[1] = s1;
  var2 = ((int *) arg1)[0];
  var5 = checkMpegLib (arg1);
  var6 = var5;
  if(var5 == 0)
  {
    var15 = ((int *) arg2)[0];
    var16 = ((int *) var2)[4];
    var19 = unRegistStream (var15, var2, 1);
    var20 = var19;
    var5 = 0x806101FE;
    if(!(var20 == 0xFFFFFFFF))
    {
      var21 = ((int *) arg3)[0];
      var24 = unRegistStream (var21, var2, 1);
      var25 = var24;
      var5 = 0x806101FE;
      if(!(var25 == 0xFFFFFFFF))
      {
        var26 = ((int *) var2)[411];
        waitSema ();
        var29 = ((int *) var20)[1];
        if(var29 == 0xFFFFFFFF)
        {
        label16:
          var6 = 0x80618001;
        }
        else
        {
          var30 = ((int *) var25)[1];
          if(var30 == 0xFFFFFFFF)
          {
            goto label16;
          }
          else
          {
            var31 = ((int *) var16)[5];
            var32 = ((int *) var29)[9];
            var33 = ((int *) var16)[4];
            var34 = ((int *) var30)[9];
            if(var33 == 0)
            {
              __asm__ ("break      0x00007;");
            }
            var35 = ((var32 - var31) / var33);
            var36 = ((var34 - var31) / var33);
            if(var35 == var36)
            {
              ((int *) var1)[0] = 0;
            }
            else
            {
              var37 = ((int *) var16)[2];
              var38 = ((int *) var16)[1];
              if(((var37 < var38)) != 0)
              {
                var40 = var35 - var36;
              }
              else
              {
                var39 = (var35 < var37);
                if(((var35 < var38)) == 0)
                {
                label26:
                  if(var39 != 0)
                  {
                  label28:
                    if(((var35 < var36)) == 0)
                    {
                      var45 = ((int *) var16)[0];
                      var44 = var35 - var36;
                    }
                    else
                    {
                      var44 = ((int *) var16)[0];
                      var45 = var36 - var35;
                    }
                    var40 = var44 - var45;
                  }
                  else
                  {
                    var40 = var35 - var36;
                    if(((var36 < var37)) != 0)
                      goto label28;
                  }
                }
                else
                {
                  var40 = var35 - var36;
                  if(!(((var36 < var38)) != 0))
                  {
                    var39 = (var35 < var37);
                    goto label26;
                  }
                }
              }
              ((int *) var1)[0] = var40;
            }
          }
        }
        var41 = ((int *) var2)[411];
        signalSema ();
        var5 = var6;
      }
    }
  }
  ra = ((int *) sp)[8];
  var7 = ((int *) sp)[7];
  var8 = ((int *) sp)[6];
  var9 = ((int *) sp)[5];
  var10 = ((int *) sp)[4];
  var11 = ((int *) sp)[3];
  var12 = ((int *) sp)[2];
  var13 = ((int *) sp)[1];
  var14 = ((int *) sp)[0];
  sp = sp + 0x30;
  return var5;
}
int mpegRingbufferQueryMemSize (int arg1){
  return ((arg1 << 0x0B) + (arg1 * 0x68));
}
int mpegRingbufferQueryPackNum (int arg1){
  return ((hi (arg1 * 0xF3A0D52D)) >> 0x0B);
}
int mpegRingbufferConstruct (int arg1, int arg2, int arg3, int arg4, int arg5, int arg6){
  sp = sp + 0xFFFFFFE0;
  ((int *) sp)[3] = s3;
  var1 = arg2 << 0x0B;
  ((int *) sp)[2] = s2;
  ((int *) sp)[0] = s0;
  var2 = arg1;
  ((int *) sp)[6] = s6;
  var3 = 0x80610022;
  ((int *) sp)[5] = s5;
  ((int *) sp)[4] = s4;
  ((int *) sp)[1] = s1;
  var4 = arg3;
  ((int *) sp)[7] = ra;
  if(!(((arg4 < (var1 + (arg2 * 0x68)))) != 0))
  {
    var5 = *((int *) mpegLibmpegSema);
    waitSema ();
    ((int *) var2)[5] = var4;
    ((int *) var2)[4] = 0x00000800;
    ((int *) var2)[8] = (var4 + var1);
    ((int *) var2)[0] = arg2;
    ((int *) var2)[6] = arg5;
    ((int *) var2)[7] = arg6;
    ((int *) var2)[3] = 0;
    ((int *) var2)[2] = 0;
    ((int *) var2)[1] = 0;
    ((int *) var2)[10] = 0;
    var8 = gp;
    ((int *) var2)[11] = var8;
    var9 = *((int *) mpegLibmpegSema);
    signalSema ();
    var3 = 0;
  }
  ra = ((int *) sp)[7];
  var12 = ((int *) sp)[6];
  var13 = ((int *) sp)[5];
  var14 = ((int *) sp)[4];
  var15 = ((int *) sp)[3];
  var16 = ((int *) sp)[2];
  var17 = ((int *) sp)[1];
  var18 = ((int *) sp)[0];
  sp = sp + 0x20;
  return var3;
}
int mpegRingbufferDestruct (){
  return 0;
}
int ringbufferPutBA (int arg1){
  if((ret=checkMpegLib (*arg1[10])))return ret;
	waitSema (*(arg1[10])[411]);
	ret = arg1[3];
	signalSema (*(arg1[10])[411]);
	return ret;
}
int ringbufferPutC (int arg1, int arg2){
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[1] = s1;
  ((int *) sp)[0] = s0;
  var1 = arg1;
  ((int *) sp)[3] = ra;
  ((int *) sp)[2] = s2;
  var2 = ((int *) arg1)[10];
  var3 = ((int *) var2)[0];
  var6 = checkMpegLib (var2);
  var7 = var6;
  if(var6 == 0)
  {
    var11 = ((int *) var3)[411];
    waitSema ();
    var14 = ((int *) var1)[3];
    var15 = MIN (arg2, var14);
    var16 = var15;
    if(!(var15 <= 0))
    {
      var17 = ((int *) var1)[0];
      var18 = ((int *) var1)[1];
      while (1) {
        var19 = !(((var17 < (var18 + var16)))) ? var16 : (var17 - var18);
        var20 = var18 + var19;
        var16 = var16 - var19;
        ((int *) var1)[1] = var20;
        if(var20 == var17)
        {
          ((int *) var1)[1] = 0;
        }
        if(!(var16 > 0))
          break;
        var18 = ((int *) var1)[1];
        continue;
      }
    }
    ((int *) var1)[3] = (var14 - var15);
    var21 = ((int *) var3)[411];
    signalSema ();
    var7 = var15;
  }
  ra = ((int *) sp)[3];
  var8 = ((int *) sp)[2];
  var9 = ((int *) sp)[1];
  var10 = ((int *) sp)[0];
  sp = sp + 0x10;
  return var7;
}
void ringbufferAvailableSize (int arg1, int arg2, int arg3){
  var1 = ((int *) arg1)[5];
  var2 = ((int *) arg1)[4];
  var3 = arg3 - var1;
  if(var2 == 0)
  {
    __asm__ ("break      0x00007;");
  }
  var4 = ((int *) arg1)[2];
  var5 = (var3 / var2);
  if(((((var5 ^ var4) < 1)) & ((0 < var3))) == 0)
  {
    var6 = ((int *) arg1)[1];
    if(((var4 < var6)) == 0)
    {
      var9 = ((int *) arg2)[0];
      if(((var4 < var5)) == 0)
      {
        if(!(((var6 < var9)) != 0))
        {
          if(!(((var5 < var6)) == 0))
          {
            if(((var5 < var9)) != 0)
            {
              ((int *) arg2)[0] = var5;
            }
            else
            {
            }
          }
        }
      label17:
      }
      else
      {
        var8 = (var5 < var9);
        if(((var6 < var9)) == 0)
        {
        label18:
          ((int *) arg2)[0] = var5;
        }
        else
        {
        label16:
          if(var8 == 0)
            goto label17;
          goto label18;
        }
      }
    }
    else
    {
      var7 = ((int *) arg2)[0];
      var8 = (var5 < var7);
      goto label16;
    }
  }
  else
  {
    ((int *) arg2)[0] = 0xFFFFFFFF;
  }
  return;
}
int deleteStuff (int arg1, int arg2, int arg3, int arg4){
  ((int *) sp)[13] = arg1;
  var1 = arg2;
  var2 = ((int *) sp)[13];
  var3 = ((int *) arg2)[0];
  ((int *) sp)[14] = arg3;
  var4 = ((int *) var2)[0];
  ((int *) sp)[15] = arg4;
  var7 = unRegistStream (var3, var4, 1);
  ((int *) sp)[19] = var7;
  var8 = ((int *) sp)[19];
  ((int *) sp)[16] = 0x80618001;
  var9 = 0x806101FE;
  if(!(var8 == 0xFFFFFFFF))
  {
    while (1) {
      var10 = ((int *) sp)[13];
      var11 = 0;
      var12 = 0;
      var15 = sub_063D8 (var10);
      var16 = ((int *) sp)[19];
      var17 = ((int *) sp)[15];
      var18 = ((int *) var1)[9];
      var19 = ((int *) var16)[3];
      var20 = ((int *) var17)[4];
      var21 = ((int *) sp)[13];
      var22 = MIN (var19, 0x63);
      ((int *) sp)[20] = (var15 + 4);
      var25 = avcDecodeYCbCr (var21, var20);
      var26 = (var18 < 1);
      ((int *) sp)[17] = var25;
      ((int *) sp)[18] = 0;
      if((((0 < var22)) & (var26 ^ 1)) == 0)
      {
        var44 = (0 < var22);
      label44:
        if(((var44 ^ 1) & (var26 ^ 1)) == 0)
        {
          ((int *) var1)[8] = 0;
        }
        else
        {
          var45 = ((int *) var1)[11];
          var46 = ((int *) var1)[8];
          var47 = ((int *) sp)[18];
          ((int *) var1)[9] = var18;
          ((int *) var1)[11] = (var45 + var11);
          ((int *) var1)[8] = (var46 + var47);
        }
        var48 = ((int *) sp)[20];
        var49 = ((int *) sp)[15];
        ((int *) (var48 + (var12 << 4)))[1073741822] = 0;
        var50 = ((int *) var49)[5];
        var51 = ((int *) sp)[13];
        var52 = ((int *) sp)[14];
        var55 = sub_05B5C (var51, (var50 + var11), var52);
        if(var55 != 0)
        {
          ((int *) sp)[16] = var55;
        label64:
          var58 = ((int *) sp)[18];
        }
        else
        {
          var56 = ((int *) var1)[12];
          if((var56 & 0x05) != 0)
          {
            var58 = ((int *) sp)[18];
          }
          else
          {
            var57 = ((int *) sp)[20];
            if((var56 & 2) == 0)
            {
            label55:
              invalidateCsc (var57);
              var81 = ((int *) sp)[15];
              var82 = ((int *) sp)[17];
              var83 = ((int *) var81)[5];
              if((((0x003FFFFF < ((var82 >> 0) & 0x1FFFFFFF))) ^ 1) == 0)
              {
                var89 = ((int *) sp)[17];
                sceKernelDcacheWritebackInvalidateRange (var89, (var83 + var11));
              }
              var84 = ((int *) sp)[20];
              var87 = sceMpegbase_BEA18F91 (var84);
              var88 = ((int *) sp)[16];
              ((int *) sp)[16] = ((var87) ? var87 : var88);
            }
            else
            {
              if(var56 < 0)
                goto label55;
            }
            goto label64;
          }
        }
      }
      else
      {
        while (1) {
          var27 = ((int *) sp)[19];
          var28 = sp;
          var29 = sp + 0x30;
          getAu (var27, var12, 1, var28, var29);
          var32 = ((int *) sp)[15];
          var33 = ((short *) var1)[14];
          var34 = ((int *) var1)[5];
          var35 = ((int *) sp)[8];
          var36 = ((int *) var32)[5];
          var37 = ((int *) sp)[7];
          var38 = ((int *) sp)[17];
          var39 = var35 - (var34 + var33);
          var18 = var18 - var39;
          var40 = (var38 + var36) + var11;
          var11 = var11 + var39;
          if(var18 <= 0)
          {
            var98 = ((int *) sp)[18];
            if(var18 != 0)
            {
              var105 = abs (var18);
              var39 = var39 - var105;
              var108 = abs (var18);
              ((short *) var1)[14] = (var39 + var33);
              var11 = var11 - var108;
            }
            else
            {
              ((short *) var1)[14] = 0;
              ((int *) sp)[18] = (var98 + 1);
            }
            var99 = ((int *) sp)[18];
            if(var99 <= 0)
            {
              var101 = ((int *) var1)[8];
              if(var101 > 0)
              {
                var100 = ((int *) var1)[6];
              label28:
                ((int *) var1)[13] = 0;
                ((int *) var1)[6] = (var100 | 1);
              label29:
                var41 = ((int *) sp)[20];
              }
              else
              {
                var102 = ((int *) var1)[13];
                var41 = ((int *) sp)[20];
                if(!(var102 != 1))
                {
                  var100 = ((int *) var1)[6];
                  goto label28;
                }
              }
            }
            else
            {
              var100 = ((int *) var1)[6];
              goto label28;
            }
          }
          else
          goto label29;
          var42 = var41 + (var12 << 4);
          ((int *) var42)[0] = ((var37 + var34) + var33);
          ((int *) var42)[2] = (var42 + 0x10);
          ((int *) var42)[1] = var40;
          if(((var39 < 0x00001000)) == 0)
          {
            ((int *) sp)[16] = 0x80618007;
            ((int *) var42)[3] = 0;
            goto label64;
          }
          else
          {
            ((int *) var42)[3] = var39;
            if(var18 <= 0)
            {
              var92 = ((int *) var1)[10];
              var12 = var12 + 1;
              if(var92 == 0)
              {
              label41:
                var44 = (var12 < var22);
              }
              else
              {
                if(var92 == 0)
                {
                  __asm__ ("break      0x00007;");
                }
                var93 = (var11 % var92);
                if(var93 == 0)
                {
                  var44 = (var12 < var22);
                }
                else
                {
                  var94 = ((int *) sp)[20];
                  var95 = var92 - var93;
                  var96 = var94 + (var12 << 4);
                  if(var92 == 0)
                  {
                    __asm__ ("break      0x00007;");
                  }
                  ((int *) var96)[3] = (!(((var95 < 0x00001000))) ? 0 : var95);
                  var12 = var12 + 1;
                  ((int *) var96)[0] = 0x0000A098;
                  ((int *) var96)[1] = (var40 + var39);
                  ((int *) var96)[2] = (var96 + 0x10);
                  var97 = ((int *) var1)[10];
                  var11 = var11 + (var97 - (var11 % var97));
                  goto label41;
                }
              }
              var26 = (var18 < 1);
              ((int *) sp)[16] = 0;
              ((int *) var1)[11] = 0;
              goto label44;
            }
            else
            {
              var43 = ((int *) sp)[18];
              var12 = var12 + 1;
              var26 = (var18 < 1);
              var44 = (var12 < var22);
              ((short *) var1)[14] = 0;
              ((int *) sp)[18] = (var43 + 1);
              if((var44 & (var26 ^ 1)) != 0)
                continue;
              break;
            }
          }
          goto label65;
        }
        goto label44;
      }
    label65:
      var59 = ((int *) sp)[19];
      var60 = sp + 0x30;
      sub_02AEC (var59, var58, var60);
      var63 = ((int *) sp)[13];
      dummy ();
      var66 = ((int *) sp)[15];
      var67 = ((int *) sp)[16];
      var68 = ((int *) var66)[5];
      var69 = ((int *) sp)[15];
      ((int *) var69)[5] = (var68 + var11);
      if(((((var12 < 0x63)) ^ 1) & (((var67 ^ 0x80618001) < 1))) != 0)
        continue;
      break;
    }
    var9 = var67;
  }
  ra = ((int *) sp)[33];
  var70 = ((int *) sp)[32];
  var71 = ((int *) sp)[31];
  var72 = ((int *) sp)[30];
  var73 = ((int *) sp)[29];
  var74 = ((int *) sp)[28];
  var75 = ((int *) sp)[27];
  var76 = ((int *) sp)[26];
  var77 = ((int *) sp)[25];
  var78 = ((int *) sp)[24];
  sp = sp + 0x90;
  return var9;
}
int mpegFlushAu (int arg1, int arg2){
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[1] = s1;
  var1 = arg2;
  ((int *) sp)[0] = s0;
  ((int *) sp)[3] = ra;
  ((int *) sp)[2] = s2;
  var2 = ((int *) arg1)[0];
  var5 = checkMpegLib (arg1);
  var6 = var5;
  if(var5 == 0)
  {
    var10 = ((int *) var2)[411];
    waitSema ();
    var13 = ((int *) var1)[0];
    var14 = ((int *) arg1)[0];
    var17 = unRegistStream (var13, var14, 1);
    if(var17 == 0xFFFFFFFF)
    {
      var23 = ((int *) var2)[411];
      signalSema ();
      var6 = 0x806101FE;
    }
    else
    {
      var18 = ((int *) var1)[11];
      if(!(var18 == 0))
      {
        var19 = ((int *) var1)[12];
        ((int *) var1)[12] = (var19 | 4);
      }
      var20 = ((int *) var2)[411];
      signalSema ();
      var6 = 0;
    }
  }
  ra = ((int *) sp)[3];
  var7 = ((int *) sp)[2];
  var8 = ((int *) sp)[1];
  var9 = ((int *) sp)[0];
  sp = sp + 0x10;
  return var6;
}
int sub_0445C (int arg1, int arg2, int arg3, int arg4){
  sp = sp + 0xFFFFFFE0;
  ((int *) sp)[5] = s5;
  ((int *) sp)[3] = s3;
  var1 = arg4;
  ((int *) sp)[2] = s2;
  ((int *) sp)[1] = s1;
  ((int *) sp)[0] = s0;
  ((int *) sp)[6] = ra;
  ((int *) sp)[4] = s4;
  var2 = ((int *) arg1)[0];
  var5 = checkMpegLib (arg1);
  var6 = var5;
  if(var5 == 0)
  {
    var14 = ((int *) var2)[411];
    waitSema ();
    var17 = ((int *) arg2)[0];
    var18 = ((int *) arg1)[0];
    var21 = unRegistStream (var17, var18, 1);
    if(var21 == 0xFFFFFFFF)
    {
      var6 = 0x806101FE;
    }
    else
    {
      if(var1 != 0)
      {
        ((int *) var1)[0] = var21;
      }
      var22 = ((int *) var21)[3];
      ((int *) arg3)[0] = var22;
    }
    var23 = ((int *) var2)[411];
    signalSema ();
    var7 = var6;
  }
  else
  {
    var7 = var6;
  }
  ra = ((int *) sp)[6];
  var8 = ((int *) sp)[5];
  var9 = ((int *) sp)[4];
  var10 = ((int *) sp)[3];
  var11 = ((int *) sp)[2];
  var12 = ((int *) sp)[1];
  var13 = ((int *) sp)[0];
  sp = sp + 0x20;
  return var7;
}
int mpegGetPcmAu (int arg1, int arg2, int arg3, int arg4){
  sp = sp + 0xFFFFFF90;
  ((int *) sp)[22] = s6;
  var1 = arg4;
  ((int *) sp)[19] = s3;
  var2 = arg1;
  ((int *) sp)[18] = s2;
  var3 = arg3;
  ((int *) sp)[17] = s1;
  var4 = arg2;
  ((int *) sp)[25] = ra;
  ((int *) sp)[24] = fp;
  ((int *) sp)[23] = s7;
  ((int *) sp)[21] = s5;
  ((int *) sp)[20] = s4;
  ((int *) sp)[16] = s0;
  var5 = ((int *) arg1)[0];
  var8 = checkMpegLib (arg1);
  if(var8 == 0)
  {
    var18 = ((int *) var5)[411];
    waitSema ();
    var21 = ((int *) var4)[0];
    var22 = ((int *) var2)[0];
    var25 = unRegistStream (var21, var22, 1);
    var26 = var25;
    if(var25 == 0xFFFFFFFF)
    {
      var68 = ((int *) var5)[411];
      signalSema ();
      var8 = 0x806101FE;
    }
    else
    {
      var27 = sp;
      var28 = sp + 0x30;
      getAu (var25, 0, 1, var27, var28);
      var31 = ((int *) sp)[12];
      if(var31 != 1)
      {
      label21:
        var65 = ((int *) var5)[411];
        signalSema ();
        var8 = 0x80618001;
      }
      else
      {
        var32 = ((int *) var4)[11];
        if(var32 != 0)
        {
        label34:
          if(!(var1 == 0))
          {
            var51 = ((int *) var4)[16];
            ((int *) var1)[0] = var51;
          }
          var54 = deleteStuff (var2, var4, 2, var3);
          var55 = ((int *) var5)[411];
          var56 = var54;
          signalSema ();
          var59 = ((int *) var4)[12];
          if((((var59 >> 2) & 1) & ((var56 < 1))) != 0)
          {
            ((int *) var4)[12] = ((var59 & 0xFFFFFFFB) | (0 & 1));
            var62 = mpegGetPcmAu (var2, var4, var3, var1);
            var56 = var62;
          }
          var8 = var56;
        }
        else
        {
          ((int *) var3)[5] = 0;
          var33 = sp + 0x30;
          while (1) {
            var34 = sp;
            getAu (var26, 0, 1, var34, var33);
            var37 = ((int *) sp)[12];
            var38 = ((int *) sp)[7];
            if(var37 != 1)
              break;
            var39 = ((int *) var4)[6];
            if((var39 & 1) == 0)
            {
              ((int *) var3)[1] = 0xFFFFFFFF;
              ((int *) var3)[2] = 0xFFFFFFFF;
              ((int *) var3)[0] = 0xFFFFFFFF;
              ((int *) var3)[3] = 0xFFFFFFFF;
            label33:
              var48 = ((unsigned char *) var38)[1];
              ((int *) var4)[16] = var48;
              var49 = ((unsigned char *) var38)[1];
              var50 = var49 & 0x0F;
              ((int *) var4)[9] = (((var50 << 2) + var50) << 0x05);
              goto label34;
            }
            else
            {
              var42 = be2 ((var38 + 2));
              ((short *) var4)[14] = var42;
              var43 = sp + 0x30;
              if(((char) var42) == 0xFFFFFFFF)
              {
                sub_02AEC (var26, 1, var43);
                var33 = sp + 0x30;
                continue;
              }
              else
              {
                var44 = ((int *) sp)[4];
                var45 = ((int *) sp)[5];
                var46 = ((int *) sp)[6];
                var47 = ((int *) sp)[3];
                ((int *) var3)[1] = var44;
                ((int *) var3)[0] = var47;
                ((int *) var3)[2] = var45;
                ((int *) var3)[3] = var46;
                ((int *) var4)[6] = 0;
                goto label33;
              }
            }
            goto label46;
          }
          goto label21;
        }
      }
    }
  }
label46:
  ra = ((int *) sp)[25];
  var9 = ((int *) sp)[24];
  var10 = ((int *) sp)[23];
  var11 = ((int *) sp)[22];
  var12 = ((int *) sp)[21];
  var13 = ((int *) sp)[20];
  var14 = ((int *) sp)[19];
  var15 = ((int *) sp)[18];
  var16 = ((int *) sp)[17];
  var17 = ((int *) sp)[16];
  sp = sp + 0x70;
  return var8;
}
int _D4DD6E75 (int arg1, int arg2, int arg3, int arg4, int arg5){
  sp = sp + 0xFFFFFF90;
  ((int *) sp)[24] = fp;
  var1 = arg3;
  ((int *) sp)[22] = s6;
  var2 = arg1;
  ((int *) sp)[21] = s5;
  var3 = arg4;
  ((int *) sp)[18] = s2;
  var4 = arg2;
  ((int *) sp)[25] = ra;
  ((int *) sp)[23] = s7;
  ((int *) sp)[20] = s4;
  ((int *) sp)[19] = s3;
  ((int *) sp)[17] = s1;
  ((int *) sp)[16] = s0;
  ((int *) sp)[13] = arg5;
  var5 = ((int *) arg1)[0];
  var8 = checkMpegLib (arg1);
  if(var8 == 0)
  {
    var18 = ((int *) var5)[411];
    waitSema ();
    var21 = ((int *) var4)[0];
    var22 = ((int *) var2)[0];
    var25 = unRegistStream (var21, var22, 1);
    var26 = var25;
    if(var25 == 0xFFFFFFFF)
    {
      var108 = ((int *) var5)[411];
      signalSema ();
      var8 = 0x806101FE;
    }
    else
    {
      var27 = sp;
      var28 = sp + 0x30;
      getAu (var25, 0, 1, var27, var28);
      var31 = ((int *) sp)[12];
      if(var31 != 1)
      {
        var107 = ((int *) var5)[411];
      label39:
        signalSema ();
        var8 = 0x80618001;
      }
      else
      {
        var32 = ((int *) var4)[11];
        if(var32 == 0)
        {
          ((int *) var3)[5] = 0;
          var93 = var26;
          while (1) {
            var94 = sp + 0x30;
            var95 = sp;
            getAu (var93, 0, 1, var95, var94);
            var98 = ((int *) sp)[12];
            var35 = var26;
            var99 = sp + 0x30;
            if(var98 != 1)
            {
              var106 = ((int *) var5)[411];
              goto label39;
            }
            else
            {
              var100 = ((int *) sp)[3];
              var101 = ((int *) sp)[4];
              if(var100 != 0xFFFFFFFF)
                break;
              var102 = ((int *) sp)[5];
              if(var101 != var100)
                break;
              var103 = ((int *) sp)[6];
              if(var102 != var101)
                break;
              if(var103 != var102)
              {
                goto label35;
              }
              else
              {
                sub_02AEC (var35, 1, var99);
                var93 = var26;
                continue;
              }
            }
            goto label84;
          }
        label34:
        label35:
          var36 = sp;
          var37 = sp + 0x30;
          getAu (var35, 0, 1, var36, var37);
          var40 = ((int *) sp)[12];
          if(var40 != 1)
          {
            var90 = ((int *) var5)[411];
            goto label39;
          }
          else
          {
            var41 = ((int *) var4)[6];
            if((var41 & 1) == 0)
            {
              var46 = ((short *) var4)[14];
            }
            else
            {
              var42 = ((int *) sp)[4];
              var43 = ((int *) sp)[5];
              var44 = ((int *) sp)[6];
              var45 = ((int *) sp)[3];
              ((short *) var4)[14] = 0;
              ((int *) var3)[0] = var45;
              ((int *) var3)[1] = var42;
              ((int *) var3)[2] = var43;
              ((int *) var3)[3] = var44;
              ((int *) var4)[6] = 0;
              var46 = ((short *) var4)[14];
            }
            var47 = ((int *) sp)[8];
            var48 = ((int *) var4)[14];
            var49 = var46 + 2;
            var50 = var47 - var49;
            if(!(var48 != 0))
            {
              ((int *) var4)[14] = 4;
              var48 = 4;
            }
            var51 = (var4 - var48) + 0x40;
            var52 = 1;
            while (1) {
              if(((var50 < var48)) == 0)
                break;
              var53 = ((int *) sp)[7];
              var51 = var51 + var50;
              strncpy (var51, (var53 + var49), var50);
              var56 = ((int *) var4)[14];
              ((int *) var4)[14] = (var56 - var50);
              var57 = sp;
              var58 = sp + 0x30;
              getAu (var26, var52, 1, var57, var58);
              var61 = ((int *) sp)[12];
              var49 = 2;
              var52 = var52 + 1;
              if(var61 != 1)
              {
                ((int *) var4)[9] = 4;
                ((int *) var4)[13] = 1;
              }
              else
              {
                var62 = ((int *) sp)[8];
                var48 = ((int *) var4)[14];
                var50 = var62 + 0xFFFFFFFE;
                continue;
              }
              goto label60;
            }
            var83 = ((int *) sp)[7];
            strncpy (var51, (var83 + var49), var48);
            ((int *) var4)[14] = 0;
            var88 = be4 ((var4 + 0x3C));
            var89 = ((int *) var4)[11];
            ((int *) var4)[9] = ((var88 - var89) + 4);
          label60:
            var34 = var2;
          label61:
            var65 = deleteStuff (var34, var4, var1, var3);
            var66 = ((int *) var5)[411];
            var67 = (var65 < 1);
            var68 = var65;
            signalSema ();
            var71 = ((int *) sp)[13];
            if((var67 & ((0 < var71))) == 0)
            {
              var74 = ((int *) var4)[12];
            }
            else
            {
              if(var1 == 3)
              {
                var82 = ((int *) var3)[4];
                var72 = var82 + 8;
              label75:
                var73 = ((int *) sp)[13];
              }
              else
              {
                if(var1 == 0x05)
                {
                  var79 = ((int *) var3)[4];
                  var72 = mpeg_C345DED2 (var79, 4);
                  var73 = ((int *) sp)[13];
                }
                else
                {
                  var72 = ((int *) var3)[4];
                  goto label75;
                }
              }
              ((int *) var73)[0] = var72;
              var74 = ((int *) var4)[12];
            }
            if((((var74 >> 2) & 1) & var67) != 0)
            {
              ((int *) var4)[12] = ((var74 & 0xFFFFFFFB) | (0 & 1));
              var75 = ((int *) sp)[13];
              var78 = _D4DD6E75 (var2, var4, var1, var3, var75);
              var68 = var78;
            }
            var8 = var68;
          }
        }
        else
        {
          var33 = ((int *) var4)[14];
          var34 = var2;
          if(var33 == 0)
            goto label61;
          var35 = var26;
          goto label34;
        }
      }
    }
  }
label84:
  ra = ((int *) sp)[25];
  var9 = ((int *) sp)[24];
  var10 = ((int *) sp)[23];
  var11 = ((int *) sp)[22];
  var12 = ((int *) sp)[21];
  var13 = ((int *) sp)[20];
  var14 = ((int *) sp)[19];
  var15 = ((int *) sp)[18];
  var16 = ((int *) sp)[17];
  var17 = ((int *) sp)[16];
  sp = sp + 0x70;
  return var8;
}
int sub_04AA0 (int arg1, int arg2, int arg3, int arg4, int arg5){
  sp = sp + 0xFFFFFF80;
  ((int *) sp)[27] = s7;
  var1 = arg4;
  ((int *) sp)[26] = s6;
  var2 = arg1;
  ((int *) sp)[21] = s1;
  var3 = arg2;
  ((int *) sp)[29] = ra;
  ((int *) sp)[28] = fp;
  ((int *) sp)[25] = s5;
  ((int *) sp)[24] = s4;
  ((int *) sp)[23] = s3;
  ((int *) sp)[22] = s2;
  ((int *) sp)[20] = s0;
  ((int *) sp)[17] = arg3;
  ((int *) sp)[18] = arg5;
  var4 = ((int *) arg1)[0];
  var7 = checkMpegLib (arg1);
  if(var7 == 0)
  {
    var17 = ((int *) var4)[411];
    waitSema ();
    var20 = ((int *) var3)[0];
    var21 = ((int *) var2)[0];
    var24 = unRegistStream (var20, var21, 1);
    var25 = var24;
    if(var24 == 0xFFFFFFFF)
    {
      var128 = ((int *) var4)[411];
      signalSema ();
      var7 = 0x806101FE;
    }
    else
    {
      var26 = sp;
      var27 = sp + 0x40;
      getAu (var24, 0, 1, var26, var27);
      var30 = ((int *) sp)[16];
      if(var30 != 1)
      {
        var127 = ((int *) var4)[411];
      label40:
        signalSema ();
        var7 = 0x80618001;
      }
      else
      {
        var31 = ((int *) var3)[14];
        var32 = ((int *) var3)[11];
        if(var31 != 0)
        {
        label22:
          if(var32 != 0)
          {
          label35:
            var49 = var25;
          label36:
            var54 = sp;
            var55 = sp + 0x40;
            getAu (var49, 0, 1, var54, var55);
            var58 = ((int *) sp)[16];
            var59 = ((int *) sp)[8];
            if(var58 != 1)
            {
            label39:
              var124 = ((int *) var4)[411];
              goto label40;
            }
            else
            {
              var60 = ((short *) var3)[14];
              var61 = ((int *) var3)[14];
              var62 = var60 + 2;
              var63 = var59 - var62;
              if(!(var61 != 0))
              {
                ((int *) var3)[14] = 8;
                var61 = 8;
              }
              var64 = 8 - var61;
              var65 = sp + 0x30;
              var66 = var65 + var64;
              while (1) {
                if(((var63 < var61)) == 0)
                  break;
                var67 = ((int *) sp)[7];
                var66 = var66 + var63;
                strncpy (var66, (var67 + var62), var63);
                var70 = ((int *) var3)[14];
                ((int *) var3)[14] = (var70 - var63);
                var71 = sp;
                var72 = sp + 0x40;
                getAu (var25, 1, 1, var71, var72);
                var75 = ((int *) sp)[16];
                var76 = sp + 0x40;
                var62 = 2;
                if(var75 != 1)
                {
                  ((int *) var3)[13] = 1;
                }
                else
                {
                  var77 = ((int *) var3)[11];
                  var78 = ((int *) sp)[8];
                  ((int *) var3)[11] = (var77 + var63);
                  var63 = var78 + 0xFFFFFFFE;
                  sub_02AEC (var25, 1, var76);
                  var61 = ((int *) var3)[14];
                  continue;
                }
                goto label56;
              }
              var117 = ((int *) sp)[7];
              strncpy (var66, (var117 + var62), var61);
              var120 = ((unsigned short *) var3)[14];
              var121 = ((unsigned short *) var3)[28];
              var122 = ((int *) var3)[11];
              var123 = ((int *) var3)[14];
              ((short *) var3)[14] = (var120 + var121);
              ((int *) var3)[11] = (var122 + var123);
              ((int *) var3)[14] = 0;
            label56:
              var81 = ((int *) var3)[14];
              var82 = 8 - var81;
              var83 = (var82 < 0x05);
              if(!(((var64 < 4)) == 0))
              {
                var84 = var82 - var64;
                if(!(var83 != 0))
                {
                  var84 = 4 - var64;
                }
                var85 = sp + 0x30;
                strncpy (((var3 + var64) + 0x3C), (var85 + var64), var84);
              }
              var88 = ((int *) sp)[18];
              if(((var83 ^ 1) & ((0 < var88))) != 0)
              {
                var112 = MAX (var64, 4);
                var113 = ((int *) sp)[18];
                var114 = sp + 0x30;
                strncpy ((var113 + var112), (var114 + var112), (var82 - var112));
                var89 = ((int *) var3)[14];
              }
              else
              {
                var89 = ((int *) var3)[14];
              }
              if(var89 == 0)
              {
                var106 = be4 ((var3 + 0x3C));
                var107 = ((int *) sp)[18];
                ((int *) var3)[9] = (var106 + 0xFFFFFFFC);
                if(var107 == 0)
                {
                label71:
                  var33 = ((int *) sp)[17];
                }
                else
                {
                  var108 = LWL (var3);
                  var109 = LWR (var3, var108, 0x3C);
                  SWL (var107, var109, 3);
                  SWR (var107, var109, 0);
                  var110 = LWL (sp, var109, 0x37);
                  var111 = LWR (sp, var110, 0x34);
                  SWL (var107, var111, 0x07);
                  SWR (var107, var111, 4);
                  var33 = ((int *) sp)[17];
                }
              }
              else
              goto label71;
            label72:
              var90 = var2;
            label73:
              var93 = deleteStuff (var90, var3, var33, var1);
              var94 = ((int *) var4)[411];
              var95 = var93;
              signalSema ();
              var98 = ((int *) var3)[12];
              if((((var98 >> 2) & 1) & ((var95 < 1))) != 0)
              {
                ((int *) var3)[12] = ((var98 & 0xFFFFFFFB) | (0 & 1));
                var99 = ((int *) sp)[17];
                var100 = ((int *) sp)[18];
                var103 = sub_04AA0 (var2, var3, var99, var1, var100);
                var95 = var103;
              }
              var7 = var95;
            }
          }
          else
          {
            ((int *) var1)[5] = 0;
            var35 = var25;
            while (1) {
              var36 = sp + 0x40;
              var37 = sp;
              getAu (var35, 0, 1, var37, var36);
              var40 = ((int *) sp)[16];
              var41 = sp + 0x40;
              if(var40 != 1)
                goto label39;
              var42 = ((int *) sp)[3];
              var43 = ((int *) sp)[4];
              if(var42 != 0xFFFFFFFF)
                break;
              var44 = ((int *) sp)[5];
              if(var43 != var42)
                break;
              var45 = ((int *) sp)[6];
              if(var44 != var43)
                break;
              if(var45 != var44)
              {
                var48 = ((int *) var3)[6];
                goto label33;
              }
              else
              {
                sub_02AEC (var25, 1, var41);
                var35 = var25;
                continue;
              }
              goto label89;
            }
            var48 = ((int *) var3)[6];
          label33:
            var49 = var25;
            if(!((var48 & 1) == 0))
            {
              var50 = ((int *) sp)[4];
              var51 = ((int *) sp)[5];
              var52 = ((int *) sp)[6];
              var53 = ((int *) sp)[3];
              ((short *) var3)[14] = 0;
              ((int *) var1)[0] = var53;
              ((int *) var1)[1] = var50;
              ((int *) var1)[2] = var51;
              ((int *) var1)[3] = var52;
              ((int *) var3)[6] = 0;
              goto label35;
            }
            goto label36;
          }
        }
        else
        {
          var33 = ((int *) sp)[17];
          if(var32 != 0)
            goto label72;
          var34 = ((int *) var3)[13];
          if(var34 == var30)
          {
            var90 = var2;
            goto label73;
          }
          else
          {
            goto label22;
          }
        }
      }
    }
  }
label89:
  ra = ((int *) sp)[29];
  var8 = ((int *) sp)[28];
  var9 = ((int *) sp)[27];
  var10 = ((int *) sp)[26];
  var11 = ((int *) sp)[25];
  var12 = ((int *) sp)[24];
  var13 = ((int *) sp)[23];
  var14 = ((int *) sp)[22];
  var15 = ((int *) sp)[21];
  var16 = ((int *) sp)[20];
  sp = sp + 0x80;
  return var7;
}
int mpeg_C345DED2 (int arg1, int arg2){
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[0] = s0;
  var1 = arg1;
  ((int *) sp)[1] = ra;
  if(arg2 == 3)
  {
    var23 = ((unsigned char *) arg1)[13];
    var2 = 0;
    if(!((var23 & 1) == 0))
    {
      var26 = mpeg_C345DED2 (arg1, 0x00001F40);
      var2 = var26;
    }
  }
  else
  {
    if(((arg2 < 4)) == 0)
    {
      if(arg2 == 0x05)
      {
        var16 = ((unsigned char *) arg1)[13];
        var2 = 0;
        if(!((var16 & 2) == 0))
        {
          var19 = mpeg_C345DED2 (arg1, 0x00001F40);
          var22 = be2 ((var19 + 0xFFFFFFFE));
          var2 = var1 + var22;
        }
      }
      else
      {
        if(((arg2 < 0x05)) != 0)
        {
          var14 = mpeg_C345DED2 (arg1, 0x00001F40);
          var15 = ((unsigned char *) var1)[13];
          var2 = var14;
          if(!((var15 & 1) == 0))
          {
            var2 = var14 + 0x40;
          }
        }
        else
        {
          if(arg2 != 0x00001F40)
          {
            var2 = 0;
          }
          else
          {
            var7 = mpeg_C345DED2 (arg1, 2);
            var8 = var7;
            if(var7 == 0)
            {
              var11 = mpeg_C345DED2 (var1, 1);
              var8 = var11;
            }
            var2 = var8 + 0x06;
          }
        }
      }
    }
    else
    {
      var2 = arg1 + 0x0E;
      if(!(arg2 == 1))
      {
        if(arg2 == 2)
        {
          var4 = ((unsigned char *) var1)[13];
          var2 = !((var4 & 2)) ? 0 : (var1 + 0x12);
        }
        else
        {
          var2 = 0;
        }
      }
    }
  }
  ra = ((int *) sp)[1];
  var3 = ((int *) sp)[0];
  sp = sp + 0x10;
  return var2;
}
int mpegGetAtracAu (int arg1, int arg2, int arg3, int arg4){
  sp = sp + 0xFFFFFF90;
  ((int *) sp)[24] = fp;
  var1 = arg4;
  ((int *) sp)[22] = s6;
  var2 = arg1;
  ((int *) sp)[21] = s5;
  var3 = arg3;
  ((int *) sp)[18] = s2;
  var4 = arg2;
  ((int *) sp)[25] = ra;
  ((int *) sp)[23] = s7;
  ((int *) sp)[20] = s4;
  ((int *) sp)[19] = s3;
  ((int *) sp)[17] = s1;
  ((int *) sp)[16] = s0;
  var5 = ((int *) arg1)[0];
  var8 = checkMpegLib (arg1);
  if(var8 == 0)
  {
    var18 = ((int *) var5)[411];
    waitSema ();
    var21 = ((int *) var4)[0];
    var22 = ((int *) var2)[0];
    var25 = unRegistStream (var21, var22, 1);
    var26 = var25;
    if(var25 == 0xFFFFFFFF)
    {
      var91 = ((int *) var5)[411];
      signalSema ();
      var8 = 0x806101FE;
    }
    else
    {
      var27 = sp;
      var28 = sp + 0x30;
      getAu (var25, 0, 1, var27, var28);
      var31 = ((int *) sp)[12];
      if(var31 != 1)
      {
      label23:
        var88 = ((int *) var5)[411];
        signalSema ();
        var8 = 0x80618001;
      }
      else
      {
        var32 = ((int *) var4)[11];
        if(var32 == 0)
        {
          ((int *) var3)[5] = 0;
        label19:
          var35 = sp;
          while (1) {
            var36 = sp + 0x30;
            getAu (var26, 0, 1, var35, var36);
            var39 = ((int *) sp)[12];
            var40 = ((int *) sp)[7];
            if(var39 != 1)
              break;
            var41 = ((int *) var4)[6];
            if((var41 & 1) == 0)
            {
              ((int *) var3)[1] = 0xFFFFFFFF;
              ((int *) var3)[2] = 0xFFFFFFFF;
              ((int *) var3)[0] = 0xFFFFFFFF;
              ((int *) var3)[3] = 0xFFFFFFFF;
            label35:
              var50 = ((short *) var4)[14];
              var51 = ((int *) sp)[8];
              var52 = ((int *) var4)[14];
              var53 = var50 + 4;
              var54 = var51 - var53;
              if(!(var52 != 0))
              {
                ((int *) var4)[14] = 4;
                var52 = 4;
              }
              var55 = (var4 - var52) + 0x40;
              var56 = 1;
              while (1) {
                var57 = var40 + var53;
                if(((var54 < var52)) == 0)
                  break;
                var55 = var55 + var54;
                strncpy (var55, var57, var54);
                var60 = ((int *) var4)[14];
                ((int *) var4)[14] = (var60 - var54);
                var61 = sp;
                var62 = sp + 0x30;
                getAu (var26, var56, 1, var61, var62);
                var65 = ((int *) sp)[12];
                var53 = 4;
                var56 = var56 + 1;
                if(var65 != 1)
                {
                  ((int *) var4)[9] = 4;
                  ((int *) var4)[13] = 1;
                }
                else
                {
                  var66 = ((int *) sp)[8];
                  var52 = ((int *) var4)[14];
                  var40 = ((int *) sp)[7];
                  var54 = var66 + 0xFFFFFFFC;
                  continue;
                }
                goto label50;
              }
              strncpy (var55, var57, var52);
              ((int *) var4)[14] = 0;
              var84 = sub_0630C ((var4 + 0x3C));
              var85 = ((int *) var4)[11];
              ((int *) var4)[9] = ((var84 - var85) + 8);
            label50:
              var34 = var2;
            label51:
              var69 = deleteStuff (var34, var4, 1, var3);
              var70 = ((int *) var5)[411];
              var71 = var69;
              signalSema ();
              var74 = (var71 < 1);
              if((var74 & ((0 < var1))) == 0)
              {
                var76 = ((int *) var4)[12];
              }
              else
              {
                var75 = ((int *) var3)[4];
                ((int *) var1)[0] = (var75 + 8);
                var76 = ((int *) var4)[12];
              }
              if((((var76 >> 2) & 1) & var74) != 0)
              {
                ((int *) var4)[12] = ((var76 & 0xFFFFFFFB) | (0 & 1));
                var79 = mpegGetAtracAu (var2, var4, var3, var1);
                var71 = var79;
              }
              var8 = var71;
            }
            else
            {
              var44 = be2 ((var40 + 2));
              ((short *) var4)[14] = var44;
              var45 = sp + 0x30;
              if(((char) var44) == 0xFFFFFFFF)
              {
                sub_02AEC (var26, 1, var45);
                var35 = sp;
                continue;
              }
              else
              {
                var46 = ((int *) sp)[4];
                var47 = ((int *) sp)[5];
                var48 = ((int *) sp)[6];
                var49 = ((int *) sp)[3];
                var40 = ((int *) sp)[7];
                ((int *) var3)[1] = var46;
                ((int *) var3)[0] = var49;
                ((int *) var3)[2] = var47;
                ((int *) var3)[3] = var48;
                ((int *) var4)[6] = 0;
                goto label35;
              }
            }
            goto label65;
          }
          goto label23;
        }
        else
        {
          var33 = ((int *) var4)[14];
          var34 = var2;
          if(var33 == 0)
            goto label51;
          goto label19;
        }
      }
    }
  }
label65:
  ra = ((int *) sp)[25];
  var9 = ((int *) sp)[24];
  var10 = ((int *) sp)[23];
  var11 = ((int *) sp)[22];
  var12 = ((int *) sp)[21];
  var13 = ((int *) sp)[20];
  var14 = ((int *) sp)[19];
  var15 = ((int *) sp)[18];
  var16 = ((int *) sp)[17];
  var17 = ((int *) sp)[16];
  sp = sp + 0x70;
  return var8;
}
int sub_052AC (int arg1, int arg2, int arg3){
  var1 = ((int *) arg1)[4];
  var2 = ((int *) arg1)[0];
  var3 = ((int *) arg1)[2];
  var4 = ((int *) arg1)[1];
  var5 = ((int *) arg1)[5];
  var6 = (arg2 < var5);
  var7 = var5 + (var1 * var2);
  var8 = (var7 < arg2);
  var9 = var5 + (var1 * var3);
  var10 = var5 + (var1 * var4);
  if((var6 | var8) != 0)
  {
  label20:
    var13 = 0x80618007;
  }
  else
  {
    var11 = (arg3 < var5);
    var12 = (var7 < arg3);
    if(!((var11 | var12) == 0))
      goto label20;
    if(((var9 < var10)) != 0)
    {
      var15 = (arg2 < arg3);
    label18:
      var13 = 1;
      if(!(var15 != 0))
      {
        var13 = ((arg2 ^ arg3)) ? 3 : 2;
      }
    }
    else
    {
      if(((var6 ^ 1) & (((var10 < arg2)) ^ 1)) == 0)
      {
        var14 = (arg2 < var9);
      label12:
        if(((var14 ^ 1) & (var8 ^ 1)) == 0)
        {
        label16:
          var13 = !(((arg2 < arg3))) ? 1 : 3;
        }
        else
        {
          if(((((arg3 < var9)) ^ 1) & (var12 ^ 1)) == 0)
          {
            goto label16;
          }
          else
          {
            var15 = (arg2 < arg3);
            goto label18;
          }
        }
      }
      else
      {
        if(((var11 ^ 1) & (((var10 < arg3)) ^ 1)) != 0)
        {
          var15 = (arg2 < arg3);
          goto label18;
        }
        else
        {
          var14 = (arg2 < var9);
          goto label12;
        }
      }
    }
  }
  return var13;
}
int mpegGetAvcAu (int arg1, int arg2, int arg3, int arg4){
  sp = sp + 0xFFFFFF60;
  ((int *) sp)[36] = fp;
  var1 = arg4;
  ((int *) sp)[35] = s7;
  var2 = arg1;
  ((int *) sp)[32] = s4;
  var3 = arg3;
  ((int *) sp)[31] = s3;
  var4 = arg2;
  ((int *) sp)[37] = ra;
  ((int *) sp)[34] = s6;
  ((int *) sp)[33] = s5;
  ((int *) sp)[30] = s2;
  ((int *) sp)[29] = s1;
  ((int *) sp)[28] = s0;
  var5 = ((int *) arg1)[0];
  var8 = checkMpegLib (arg1);
  var9 = var8;
  if(!(var8 != 0))
  {
    var10 = ((int *) var4)[2];
    var9 = 0x806101FE;
    if(!(var10 == 0xFFFFFFFF))
    {
      var11 = ((int *) var5)[411];
      waitSema ();
      var14 = ((int *) var4)[0];
      var15 = ((int *) var2)[0];
      var18 = unRegistStream (var14, var15, 1);
      if(var18 == 0xFFFFFFFF)
      {
      label22:
        var128 = ((int *) var5)[411];
        signalSema ();
        var9 = 0x80618001;
      }
      else
      {
        var19 = sp;
        while (1) {
          var20 = sp + 0x60;
          getAu (var18, 0, 1, var19, var20);
          var23 = ((int *) sp)[24];
          var24 = sp + 0x30;
          var25 = sp + 0x60;
          if(var23 != 1)
            break;
          var26 = ((int *) var4)[11];
          if(var26 != 0)
          {
            var79 = ((int *) var4)[3];
          label45:
            var82 = sub_063D0 (var79);
            var83 = ((int *) var4)[4];
            var86 = sub_063AC (var82, var83);
            var89 = sub_06340 (var86);
            if(var89 == 0)
            {
              var124 = ((int *) var4)[12];
            label61:
              var92 = (var124 & 0x7FFFFFFF) | (0 & 1);
            }
            else
            {
              var90 = ((int *) var5)[3];
              if(var90 == 0)
              {
                var119 = sub_063D0 (var79);
                var122 = sub_063A4 (var119);
                var123 = ((int *) var4)[4];
                if(var123 != (var122 + 0xFFFFFFFF))
                {
                  var91 = ((int *) var4)[12];
                label63:
                  var92 = var91 | 0x80000000;
                }
                else
                {
                  var124 = ((int *) var4)[12];
                  goto label61;
                }
              }
              else
              {
                var91 = ((int *) var4)[12];
                goto label63;
              }
            }
            ((int *) var4)[12] = var92;
            if(!(var1 == 0))
            {
              var93 = ((int *) var4)[12];
              ((int *) var1)[0] = (var93 >> 0x1F);
              var96 = getChar (var86);
              var97 = ((int *) var1)[0];
              ((int *) var1)[0] = (var97 | (var96 << 1));
            }
            var100 = deleteStuff (var2, var4, 0, var3);
            var101 = var100;
            if(var100 == 0)
            {
              var111 = sub_063D0 (var79);
              var114 = sub_063A4 (var111);
              var115 = ((int *) var4)[4];
              var116 = var115 + 1;
              if(!(((var115 < (var114 + 0xFFFFFFFF))) != 0))
              {
                var116 = 0x00007FFF;
              }
              ((int *) var4)[4] = var116;
            }
            var102 = ((int *) var5)[411];
            signalSema ();
            var105 = ((int *) var4)[12];
            if((((var105 >> 2) & 1) & ((var101 < 1))) != 0)
            {
              ((int *) var4)[12] = ((var105 & 0xFFFFFFFB) | (0 & 1));
              var108 = mpegGetAvcAu (var2, var4, var3, var1);
              var101 = var108;
            }
            var9 = var101;
          }
          else
          {
            ((int *) var3)[5] = 0;
            var27 = ((int *) var4)[4];
            var28 = ((int *) sp)[4];
            if(var27 != 0x00007FFF)
            {
              ((int *) var3)[1] = 0xFFFFFFFF;
              ((int *) var3)[2] = 0xFFFFFFFF;
              ((int *) var3)[0] = 0xFFFFFFFF;
              ((int *) var3)[3] = 0xFFFFFFFF;
            label38:
              var68 = ((int *) var4)[3];
              var71 = sub_063D0 (var68);
              var72 = ((int *) var4)[4];
              var75 = sub_063AC (var71, var72);
              var78 = sub_06384 (var75);
              var79 = ((int *) var4)[3];
              ((int *) var4)[9] = var78;
              goto label45;
            }
            else
            {
              var29 = ((int *) sp)[5];
              var30 = ((int *) sp)[6];
              var31 = ((int *) sp)[3];
              var32 = ((int *) var4)[2];
              ((int *) var3)[1] = var28;
              ((int *) var3)[0] = var31;
              ((int *) var3)[2] = var29;
              ((int *) var3)[3] = var30;
              getAu (var32, 0, 1, var24, var25);
              var35 = ((int *) sp)[24];
              var36 = ((int *) sp)[19];
              if(var35 != var23)
                break;
              var37 = ((int *) var5)[4];
              var38 = ((int *) sp)[7];
              var41 = sub_052AC (var37, var38, var36);
              var42 = sp + 0x60;
              if(var41 != var35)
              {
                sub_02AEC (var32, 1, var42);
                var63 = ((int *) sp)[20];
                if(((var63 < 0x00000801)) == 0)
                {
                  var125 = ((int *) var5)[411];
                  signalSema ();
                  var9 = 0x80618007;
                }
                else
                {
                  var64 = ((int *) var4)[3];
                  var65 = ((int *) sp)[19];
                  strncpy (var64, var65, var63);
                  ((int *) var4)[4] = 0;
                  ((short *) var4)[14] = 0;
                  goto label38;
                }
              }
              else
              {
                var43 = ((int *) var5)[411];
                signalSema ();
                var48 = mpegNextAvcRpAu (var2, var4);
                if(var48 != 0)
                {
                  var9 = ((var48 ^ 0x80618004)) ? var48 : 0x80618001;
                }
                else
                {
                  var49 = ((int *) var5)[411];
                  waitSema ();
                  var19 = sp;
                  continue;
                }
              }
            }
          }
          goto label92;
        }
        goto label22;
      }
    }
  }
label92:
  ra = ((int *) sp)[37];
  var52 = ((int *) sp)[36];
  var53 = ((int *) sp)[35];
  var54 = ((int *) sp)[34];
  var55 = ((int *) sp)[33];
  var56 = ((int *) sp)[32];
  var57 = ((int *) sp)[31];
  var58 = ((int *) sp)[30];
  var59 = ((int *) sp)[29];
  var60 = ((int *) sp)[28];
  sp = sp + 0xA0;
  return var9;
}
int mpegGetAvcEsAu (int arg1, int arg2, int arg3, int arg4){
  sp = sp + 0xFFFFFFC0;
  ((int *) sp)[12] = s4;
  ((int *) sp)[11] = s3;
  ((int *) sp)[10] = s2;
  var1 = arg1;
  ((int *) sp)[9] = s1;
  ((int *) sp)[8] = s0;
  ((int *) sp)[13] = ra;
  var2 = arg4;
  var5 = checkMpegLib (arg1);
  if(var5 == 0)
  {
    ((int *) var2)[5] = 0;
    var14 = sub_063D8 (var1);
    ((int *) sp)[4] = 0;
    var15 = ((int *) var14)[0];
    var16 = sp;
    ((int *) sp)[5] = var15;
    ((int *) sp)[6] = var14;
    var19 = nalCpy (var1, var16, arg2, arg3, 0, var2);
    var20 = var19;
    var21 = sp;
    if(!(var19 != 0))
    {
      var24 = sub_05C0C (var1, var21, var2);
      var25 = var24;
      if(!(var24 != 0))
      {
        ((int *) sp)[4] = 0;
        var25 = 0;
        var26 = ((int *) sp)[6];
        var27 = ((int *) var26)[0];
        ((int *) sp)[5] = var27;
      }
      var20 = var25;
    }
    dummy ();
    var6 = var20;
  }
  else
  {
    var6 = var5;
  }
  ra = ((int *) sp)[13];
  var7 = ((int *) sp)[12];
  var8 = ((int *) sp)[11];
  var9 = ((int *) sp)[10];
  var10 = ((int *) sp)[9];
  var11 = ((int *) sp)[8];
  sp = sp + 0x40;
  return var6;
}
int mpegGetAvcNalAu (int arg1, int arg2, int arg3){
  sp = sp + 0xFFFFFFB0;
  ((int *) sp)[15] = s7;
  var1 = arg1;
  ((int *) sp)[14] = s6;
  var2 = arg3;
  ((int *) sp)[12] = s4;
  var3 = arg2;
  ((int *) sp)[17] = ra;
  ((int *) sp)[16] = fp;
  ((int *) sp)[13] = s5;
  ((int *) sp)[11] = s3;
  ((int *) sp)[10] = s2;
  ((int *) sp)[9] = s1;
  ((int *) sp)[8] = s0;
  var6 = checkMpegLib (arg1);
  ra = ((int *) sp)[17];
  if(!(var6 != 0))
  {
    ((int *) var2)[5] = 0;
    var7 = ((int *) var3)[4];
    var8 = 0;
    if(var7 == 0)
    {
    label55:
      var6 = 0x806101FE;
    }
    else
    {
      if(((var7 < 3)) != 0)
      {
      label8:
        var20 = sub_063D8 (var1);
        ((int *) sp)[4] = 0;
        var21 = ((int *) var3)[7];
        var22 = ((int *) var20)[0];
        ((int *) sp)[6] = var20;
        ((int *) sp)[5] = var22;
        if((var21 & 1) == 0)
        {
        label19:
          if((var21 & 2) == 0)
          {
            var25 = ((int *) var3)[6];
          label30:
            var26 = ((int *) var3)[5];
            if(var25 <= 0)
            {
            label47:
              var45 = sp;
              var48 = sub_05C0C (var1, var45, var2);
              var49 = var48;
              if(!(var48 != 0))
              {
                ((int *) sp)[4] = 0;
                var49 = 0;
                var50 = ((int *) sp)[6];
                var51 = ((int *) var50)[0];
                ((int *) sp)[5] = var51;
              }
              var35 = var49;
            }
            else
            {
              var27 = ((int *) var3)[4];
              while (1) {
                var30 = beN (var26, var27);
                var31 = ((int *) var3)[4];
                var32 = var30;
                var25 = var25 - (var31 + var30);
                var33 = sp;
                var34 = var26 + var31;
                var35 = 0x80618007;
                if(((var25 >> 0x1F) | ((var30 < 1))) != 0)
                  break;
                if(var8 == 0)
                {
                  var37 = 0;
                }
                else
                {
                  var36 = ((unsigned char *) var34)[0];
                  var37 = 1;
                  if(!(((((var36 & 0x1F) + 0xFFFFFFF9) < 2)) == 0))
                  {
                    var37 = 0;
                  }
                }
                var40 = nalCpy (var1, var33, (var37 + 0x0000A188), (4 - var37), 0, var2);
                var8 = 1;
                var35 = var40;
                var41 = sp;
                var26 = var34 + var32;
                if(var40 != 0)
                  break;
                var44 = nalCpy (var1, var41, var34, var32, 0, var2);
                var35 = var44;
                if(var44 != 0)
                  break;
                if(!(var25 > 0))
                  goto label47;
                var27 = ((int *) var3)[4];
                continue;
              }
            }
          }
          else
          {
            var24 = ((int *) var3)[2];
            if(var24 != 0)
            {
              var54 = sp;
              var57 = nalCpy (var1, var54, 0x0000A188, 4, 0, var2);
              var35 = var57;
              if(!(var57 != 0))
              {
                var58 = ((int *) var3)[2];
                var59 = ((int *) var3)[3];
                var60 = sp;
                var63 = nalCpy (var1, var60, var58, var59, 0, var2);
                var35 = var63;
                if(!(var63 != 0))
                {
                  var8 = 1;
                label29:
                  var25 = ((int *) var3)[6];
                  goto label30;
                }
              }
            }
            else
            goto label29;
          }
        }
        else
        {
          var23 = ((int *) var3)[0];
          if(!(var23 != 0))
            goto label19;
          var64 = sp;
          var67 = nalCpy (var1, var64, 0x0000A188, 4, 0, var2);
          var35 = var67;
          if(!(var67 != 0))
          {
            var68 = ((int *) var3)[0];
            var69 = ((int *) var3)[1];
            var70 = sp;
            var73 = nalCpy (var1, var70, var68, var69, 0, var2);
            var35 = var73;
            if(!(var73 != 0))
            {
              var21 = ((int *) var3)[7];
              var8 = 1;
              goto label19;
            }
          }
        }
        dummy ();
        var6 = var35;
      }
      else
      {
        if(var7 == 4)
          goto label8;
        goto label55;
      }
    }
    ra = ((int *) sp)[17];
  }
  var9 = ((int *) sp)[16];
  var10 = ((int *) sp)[15];
  var11 = ((int *) sp)[14];
  var12 = ((int *) sp)[13];
  var13 = ((int *) sp)[12];
  var14 = ((int *) sp)[11];
  var15 = ((int *) sp)[10];
  var16 = ((int *) sp)[9];
  var17 = ((int *) sp)[8];
  sp = sp + 0x50;
  return var6;
}
void sub_05A7C (int arg1, int arg2, int arg3, int arg4, int arg5){
  arg1[0] = arg2;
  arg1[1] = arg3;
  arg1[2] = arg4;
  if(((arg5 >= 0x00001000)){
    arg1[3] = 0;
		return 0x806101FE;
  }
	arg1[3] = arg5;
	return 0;
}
void sub_05AB0 (int arg1, int arg2){
  arg1[2] = arg2;
}
int mpegQueryUserdataEsSize2 (int arg1, int arg2, int arg3, int arg4){
  return sub_04AA0 (arg1, arg2, 3, arg3, arg4);
}
int mpeg_D4DD6E75 (int arg1, int arg2, int arg3, int arg4){
  return _D4DD6E75 (arg1, arg2, 0x05, arg3, arg4);
}
void invalidateCsc (int arg1){
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[2] = ra;
  ((int *) sp)[1] = s1;
  var1 = 0;
  ((int *) sp)[0] = s0;
  var2 = arg1;
  var3 = ((int *) var2)[3];
  while (1) {
    var4 = ((int *) var2)[0];
    var1 = var1 + 1;
    sceKernelDcacheWritebackInvalidateRange (var4, (var3 & 0x00000FFF));
    var7 = ((int *) var2)[2];
    var2 = var7;
    if(var7 == 0)
      break;
    if(!(((var1 < 0x64)) != 0))
      break;
    var3 = ((int *) var2)[3];
    continue;
  }
  ra = ((int *) sp)[2];
  var8 = ((int *) sp)[1];
  var9 = ((int *) sp)[0];
  sp = sp + 0x10;
  return;
}
int sub_05B5C (int arg1, int arg2, int arg3){
  var1 = ((int *) arg1)[0];
  var2 = 0x80618007;
  if(!(((arg3 < 0x07)) == 0))
  {
    var3 = ((int *) var1)[414];
    if(((var3 < 0x06)) == 0)
    {
      if(var3 != 0x06)
      {
      label13:
        var4 = ((int *) ((arg3 << 2) + 0x0000A118))[0];
      }
      else
      {
        var4 = ((int *) ((arg3 << 2) + 0x0000A118))[21];
      }
    }
    else
    {
      if(((var3 < 4)) == 0)
      {
        var4 = ((int *) ((arg3 << 2) + 0x0000A118))[14];
      }
      else
      {
        if(var3 == 3)
        {
          var4 = ((int *) ((arg3 << 2) + 0x0000A118))[7];
        }
        else
        {
          goto label13;
        }
      }
    }
    var2 = !(((var4 < arg2))) ? 0 : 0x80618007;
  }
  return var2;
}
int sub_05C0C (int arg1, int arg2, int arg3){
  sp = sp + 0xFFFFFFE0;
  ((int *) sp)[3] = s3;
  var1 = 0;
  ((int *) sp)[2] = s2;
  ((int *) sp)[1] = s1;
  ((int *) sp)[4] = ra;
  ((int *) sp)[0] = s0;
  var2 = ((int *) arg2)[6];
  var3 = ((int *) arg2)[4];
  var4 = var2 + 4;
  if(var3 != 0)
  {
    var9 = ((int *) arg3)[4];
    var12 = avcDecodeYCbCr (arg1, var9);
    var13 = ((int *) arg2)[4];
    var14 = var12;
    ((int *) (var4 + (var13 << 4)))[1073741822] = 0;
    invalidateCsc (var4);
    var17 = ((int *) arg3)[5];
    if((((0x003FFFFF < ((var14 >> 0) & 0x1FFFFFFF))) ^ 1) == 0)
    {
      sceKernelDcacheWritebackInvalidateRange (var14, var17);
    }
    var1 = sceMpegbase_BEA18F91 (var4);
    ra = ((int *) sp)[4];
  }
  else
  {
    ra = ((int *) sp)[4];
  }
  var5 = ((int *) sp)[3];
  var6 = ((int *) sp)[2];
  var7 = ((int *) sp)[1];
  var8 = ((int *) sp)[0];
  sp = sp + 0x20;
  return var1;
}
int nalCpy (int arg1, int arg2, int arg3, int arg4, int arg5, int arg6){
  var1 = arg1;
  var2 = arg6;
  var3 = arg2;
  var4 = ((int *) arg6)[5];
  var7 = sub_05B5C (arg1, (var4 + arg4), arg5);
  var8 = var7;
  if(var7 != 0)
  {
  label18:
    ra = ((int *) sp)[5];
  }
  else
  {
    var9 = ((int *) var2)[4];
    var12 = avcDecodeYCbCr (var1, var9);
    var13 = ((int *) var2)[5];
    ((int *) var3)[0] = arg3;
    ((int *) var3)[1] = (var12 + var13);
    ((int *) var3)[2] = arg4;
    ((int *) var3)[3] = 0;
    while (1) {
      var16 = sub_05DF4 (var3);
      var8 = var16;
      if(var16 != 0)
        break;
      var17 = ((int *) var3)[3];
      var18 = ((int *) var3)[2];
      var19 = ((int *) var3)[0];
      var20 = ((int *) var3)[1];
      ((int *) var3)[2] = (var18 - var17);
      var21 = ((int *) var2)[5];
      ((int *) var3)[0] = (var19 + var17);
      ((int *) var2)[5] = (var21 + var17);
      var22 = ((int *) var3)[4];
      var23 = ((int *) var3)[5];
      ((int *) var3)[1] = (var20 + var17);
      if(((var22 < var23)) != 0)
        break;
      var24 = ((int *) var3)[3];
      var25 = ((int *) var3)[2];
      ra = ((int *) sp)[5];
      if(!(((var24 < var25)) == 0))
      {
        var28 = sub_05C0C (var1, var3, var2);
        var29 = var28;
        if(!(var28 != 0))
        {
          ((int *) var3)[4] = 0;
          var29 = 0;
          var30 = ((int *) var3)[6];
          var31 = ((int *) var30)[0];
          ((int *) var3)[5] = var31;
        }
        var8 = var29;
        if(var29 == 0)
          continue;
        break;
      }
      goto label19;
    }
    goto label18;
  }
label19:
  return var8;
}
int sub_05DF4 (int arg1){
  var1 = ((int *) arg1)[4];
  var2 = ((int *) arg1)[5];
  var3 = ((int *) arg1)[6];
  var4 = arg1;
  ((int *) arg1)[3] = 0;
  var5 = 0;
  var6 = ((int *) var4)[0];
  var7 = ((int *) var4)[1];
  if(!(((var1 < var2)) == 0))
  {
    var8 = ((int *) var4)[2];
    if(!(var8 <= 0))
    {
      var9 = ((int *) var4)[3];
      while (1) {
        var10 = var8 - var9;
        var11 = (((var10 < 0x00000FF0))) ? var10 : 0x00000FF0;
        var12 = (var3 + 4) + (var1 << 4);
        ((int *) var12)[2] = (var12 + 0x10);
        var5 = 0;
        ((int *) var12)[0] = var6;
        var6 = var6 + 0x00000FF0;
        ((int *) var12)[1] = var7;
        if(((var11 < 0x00001000)) == 0)
        {
          var5 = 0x806101FE;
          ((int *) var12)[3] = 0;
        }
        else
        {
          ((int *) var12)[3] = var11;
          var7 = var7 + 0x00000FF0;
          var13 = ((int *) var4)[4];
          var14 = ((int *) var4)[3];
          var15 = ((int *) var4)[5];
          var16 = var13 + 1;
          var17 = var14 + var11;
          var1 = var16;
          ((int *) var4)[3] = var17;
          ((int *) var4)[4] = var16;
          if(((var16 < var15)) == 0)
            break;
          var8 = ((int *) var4)[2];
          if(!(((var17 < var8)) != 0))
            break;
          var9 = ((int *) var4)[3];
          continue;
        }
      }
    }
  }
  return var5;
}
int mpegMallocAvcEsBuf (int arg1){
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[1] = s1;
  var1 = 0;
  ((int *) sp)[2] = ra;
  ((int *) sp)[0] = s0;
  var2 = ((int *) arg1)[0];
  var5 = checkMpegLib (arg1);
  var6 = 0;
  if(!(var5 != 0))
  {
    var7 = ((int *) var2)[411];
    waitSema ();
    var10 = ((int *) var2)[415];
    var11 = 0;
    if(!(var10 <= 0))
    {
      var12 = 0 + var2;
      while (1) {
        var13 = ((unsigned char *) var12)[1664];
        if(var13 == 0)
          break;
        var11 = var11 + 1;
        if(((var11 < var10)) != 0)
        {
          var12 = var11 + var2;
          continue;
        }
        else
        {
        }
        goto label15;
      }
      var1 = var11 + 1;
      ((char *) var12)[1664] = 1;
    }
  label15:
    var14 = ((int *) var2)[411];
    signalSema ();
    var6 = var1;
  }
  ra = ((int *) sp)[2];
  var17 = ((int *) sp)[1];
  var18 = ((int *) sp)[0];
  sp = sp + 0x10;
  return var6;
}
int mpegFreeAvcEsBuf (int arg1, int arg2){
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[1] = s1;
  var1 = arg2;
  ((int *) sp)[0] = s0;
  ((int *) sp)[3] = ra;
  ((int *) sp)[2] = s2;
  var2 = ((int *) arg1)[0];
  var5 = checkMpegLib (arg1);
  var6 = var5;
  if(var5 == 0)
  {
    var11 = ((int *) var2)[411];
    waitSema ();
    if(var1 <= 0)
    {
    label9:
      var6 = 0x806101FE;
    }
    else
    {
      var14 = ((int *) var2)[415];
      if(((var14 < var1)) != 0)
        goto label9;
      ((char *) (var1 + var2))[1663] = 0;
    }
    var15 = ((int *) var2)[411];
    signalSema ();
    var7 = var6;
  }
  else
  {
    var7 = var6;
  }
  ra = ((int *) sp)[3];
  var8 = ((int *) sp)[2];
  var9 = ((int *) sp)[1];
  var10 = ((int *) sp)[0];
  sp = sp + 0x10;
  return var7;
}
int mpegQueryAtracEsSize (int arg1, int arg2, int arg3){
  if((ret=checkMpegLib (arg1)))return ret;
	if(*arg1[414] == 3){
		*arg2 = 0x00001040;
		*arg3 = 0x00008000;
	}else{
		*arg2 = 0x00000840;
		*arg3 = 0x00002000;
	}
  return 0;
}
int mpeg_988E9E12 (int arg1, int arg2, int arg3){
  sp = sp + 0xFFFFFFE0;
  ((int *) sp)[6] = s6;
  var1 = 0;
  ((int *) sp)[5] = s5;
  ((int *) sp)[4] = s4;
  ((int *) sp)[7] = s7;
  ((int *) sp)[3] = s3;
  ((int *) sp)[2] = s2;
  ((int *) sp)[1] = s1;
  ((int *) sp)[0] = s0;
  if(!(arg1 <= 0))
  {
    while (1) {
      var2 = var1 << 2;
      var3 = var2 + arg2;
      var4 = ((unsigned char *) var3)[0];
      var5 = *((int *) 0x0000A278);
      var6 = *((int *) 0x0000A27C);
      var7 = *((int *) 0x0000A26C);
      var8 = var6 << 0x07;
      var9 = MAX ((var4 - var5), 0);
      var10 = ((unsigned char *) var3)[1];
      var11 = *((int *) 0x0000A270);
      var12 = ((unsigned char *) var3)[2];
      var13 = var10 - var8;
      var14 = *((int *) 0x0000A254);
      var15 = var12 - var8;
      var16 = var2 + arg3;
      var17 = *((int *) 0x0000A258);
      var18 = *((int *) 0x0000A260);
      var19 = *((int *) 0x0000A264);
      var20 = *((int *) 0x0000A274);
      var21 = *((int *) 0x0000A25C);
      var22 = *((int *) 0x0000A268);
      var1 = var1 + 1;
      var23 = ((var7 * var9) + (var11 * var13)) + (var20 * var15);
      var24 = ((var14 * var9) + (var17 * var13)) + (var21 * var15);
      var25 = ((var18 * var9) + (var19 * var13)) + (var22 * var15);
      var26 = MAX (((var23 + ((var23 >> 0x1F) >> 0x19)) >> 0x07), 0);
      var27 = MAX (((var24 + ((var24 >> 0x1F) >> 0x19)) >> 0x07), 0);
      var28 = MAX (((var25 + ((var25 >> 0x1F) >> 0x19)) >> 0x07), 0);
      ((char *) var16)[0] = (!(((var27 < 0x00000100))) ? 0xFF : var27);
      ((char *) var16)[1] = (!(((var28 < 0x00000100))) ? 0xFF : var28);
      ((char *) var16)[2] = (!(((var26 < 0x00000100))) ? 0xFF : var26);
      var29 = ((unsigned char *) var3)[3];
      ((char *) var16)[3] = var29;
      if(((var1 < arg1)) != 0)
        continue;
      break;
    }
  }
  var30 = ((int *) sp)[7];
  var31 = ((int *) sp)[6];
  var32 = ((int *) sp)[5];
  var33 = ((int *) sp)[4];
  var34 = ((int *) sp)[3];
  var35 = ((int *) sp)[2];
  var36 = ((int *) sp)[1];
  var37 = ((int *) sp)[0];
  sp = sp + 0x20;
  return 0;
}
int avcDecodeYCbCr (int arg1, int arg2){
  var1 = *arg1;
	if(arg2<=0)return arg2;
	if(*arg1[415]<arg2)return arg2;
	if(((unsigned char *) (arg2 + var1))[1663]!=1)return arg2;
	return *arg1[416+arg2];
}
int mpegQueryPcmEsSize (int arg1, int arg2, int arg3){
  if((ret=checkMpegLib (arg1)))return ret;
	*arg2 = 0x00000140;
	*arg3 = 0x00000140;
  return 0;
}
int mpeg_11CAB459 (int arg1, int arg2, int arg3){
  if((ret=checkMpegLib (arg1)))return ret;
	*arg2 = 0x00019100;
	*arg3 = 0x0002A300;
  return 0;
}
int mpegQueryUserdataEsSize (int arg1, int arg2, int arg3){
  if((ret=checkMpegLib (arg1)))return ret;
	*arg2 = 0x000A0000;
	*arg3 = 0x000A0000;
  return 0;
}
int sub_0630C (int arg1){
  return (((be2(arg1+2)&0x03FF)*8)+8);
}
int getChar (int arg1){
  return (((unsigned char *) arg1)[0] & 0xF);
}
int sub_06340 (int arg1){
  return (be3(arg1+1) >> 0x17);
}
void sub_06360 (int arg1, int arg2){
  if(arg2 != 0)
  {
    var3 = ((unsigned char *) arg1)[1];
    var2 = var3 | 0xFFFFFF80;
  }
  else
  {
    var1 = ((unsigned char *) arg1)[1];
    var2 = var1 & 0x7F;
  }
  ((char *) arg1)[1] = var2;
  return;
}
int sub_06384 (int arg1){
  return (be3(arg1+1) & 0x001FFFFF);
}
int sub_063A4 (int arg1){
  var1 = ((unsigned char *) arg1)[3];
  return var1;
}
int sub_063AC (int arg1, int arg2){
  var1 = ((unsigned char *) arg1)[3];
  var2 = 0;
  if(!(((arg2 < var1)) == 0))
  {
    var2 = (arg1 + (arg2 << 2)) + 4;
  }
  return var2;
}
int sub_063D0 (int arg1){
  return (arg1 + 14);
}
int sub_063D8 (int arg1){
  return ((*arg1 + (*arg1[9] * 0x00000644)) + 0x28);
}
void dummy (){
  return;
}
void initVSH (){
  *((int *) 0x0000A27C) = 1;
  *((int *) 0x0000A254) = 0x95;
  *((int *) 0x0000A25C) = 0xCC;
  *((int *) 0x0000A264) = 0xFFFFFFCE;
  *((int *) 0x0000A268) = 0xFFFFFF98;
  *((int *) 0x0000A26C) = 0x95;
  *((int *) 0x0000A270) = 0x00000102;
  *((int *) 0x0000A278) = 0x10;
  *((int *) 0x0000A258) = 0;
  *((int *) 0x0000A260) = 0x95;
  *((int *) 0x0000A274) = 0;
  return;
}
int mpegNextAvcRpAu (int arg1, int arg2){
  sp = sp + 0xFFFFFF90;
  ((int *) sp)[21] = s5;
  ((int *) sp)[19] = s3;
  var1 = arg2;
  ((int *) sp)[16] = s0;
  ((int *) sp)[25] = ra;
  ((int *) sp)[24] = fp;
  ((int *) sp)[23] = s7;
  ((int *) sp)[22] = s6;
  ((int *) sp)[20] = s4;
  ((int *) sp)[18] = s2;
  ((int *) sp)[17] = s1;
  var2 = ((int *) arg1)[0];
  var5 = checkMpegLib (arg1);
  var6 = var5;
  var7 = var5;
  if(!(var5 != 0))
  {
    var8 = ((int *) var1)[2];
    var7 = 0x806101FE;
    if(!(var8 == 0xFFFFFFFF))
    {
      var9 = ((int *) var2)[411];
      waitSema ();
      var12 = ((int *) arg1)[0];
      var13 = ((int *) var1)[0];
      var16 = unRegistStream (var13, var12, 1);
      var17 = var16;
      if(var16 == 0xFFFFFFFF)
      {
        var52 = ((int *) var2)[411];
        signalSema ();
        var7 = 0x806101FE;
      }
      else
      {
        var18 = ((int *) var1)[2];
        var19 = sp;
        var20 = sp + 0x30;
        getAu (var18, 0, 1, var19, var20);
        var23 = ((int *) sp)[12];
        if(var23 == 1)
        {
          var24 = ((int *) sp)[7];
        }
        else
        {
          var6 = 0x80618004;
          var24 = 0xFFFF0000;
        }
        var25 = ((int *) var17)[3];
        var26 = 0;
        if(var25 <= 0)
        {
        label31:
          var39 = ((int *) var1)[12];
        }
        else
        {
          while (1) {
            var27 = sp;
            var28 = sp + 0x30;
            getAu (var17, 0, 1, var27, var28);
            var26 = var26 + 1;
            if(var24 == 0xFFFF0000)
            {
            label28:
              var36 = sp + 0x30;
              sub_02AEC (var17, 1, var36);
              if(((var26 < var25)) != 0)
                continue;
              break;
            }
            else
            {
              var31 = ((int *) var2)[4];
              var32 = ((int *) sp)[7];
              var35 = sub_052AC (var31, var24, var32);
              if(!(var35 == 1))
                goto label28;
              var39 = ((int *) var1)[12];
            }
            goto label32;
          }
          goto label31;
        }
      label32:
        ((int *) var1)[4] = 0x00007FFF;
        ((int *) var1)[12] = ((var39 & 0xFFFFFFFB) | (0 & 1));
        ((int *) var1)[11] = 0;
        var40 = ((int *) var2)[411];
        signalSema ();
        var7 = var6;
      }
    }
  }
  ra = ((int *) sp)[25];
  var43 = ((int *) sp)[24];
  var44 = ((int *) sp)[23];
  var45 = ((int *) sp)[22];
  var46 = ((int *) sp)[21];
  var47 = ((int *) sp)[20];
  var48 = ((int *) sp)[19];
  var49 = ((int *) sp)[18];
  var50 = ((int *) sp)[17];
  var51 = ((int *) sp)[16];
  sp = sp + 0x70;
  return var7;
}
int mpeg_B27711A8 (int arg1, int arg2, int arg3, int arg4){
  sp = sp + 0xFFFFFFA0;
  ((int *) sp)[20] = s4;
  ((int *) sp)[19] = s3;
  var1 = arg3;
  ((int *) sp)[18] = s2;
  var2 = arg4;
  ((int *) sp)[17] = s1;
  var3 = arg2;
  ((int *) sp)[16] = s0;
  ((int *) sp)[22] = ra;
  ((int *) sp)[21] = s5;
  var4 = ((int *) arg1)[0];
  var7 = checkMpegLib (arg1);
  if(var7 == 0)
  {
    var14 = ((int *) var4)[411];
    waitSema ();
    var17 = ((int *) arg1)[0];
    var18 = ((int *) var3)[0];
    var21 = unRegistStream (var18, var17, 1);
    if(var21 == 0xFFFFFFFF)
    {
    label11:
      var75 = ((int *) var4)[411];
      signalSema ();
      var7 = 0x806101FE;
    }
    else
    {
      var22 = ((int *) var3)[2];
      if(var22 == 0xFFFFFFFF)
        goto label11;
      var23 = var1;
      if(var1 != 0)
      {
      label17:
        var59 = sp;
        var60 = sp + 0x30;
        getAu (var22, var23, 1, var59, var60);
        var63 = ((int *) sp)[12];
        if(var63 != 1)
        {
          var71 = ((int *) sp)[8];
          var72 = ((int *) var4)[411];
          signalSema ();
          var7 = 0x80618004;
        }
        else
        {
          var64 = ((int *) sp)[8];
          var65 = ((int *) sp)[7];
          if(((var64 < 0x00000801)) == 0)
          {
            var68 = ((int *) var4)[411];
            signalSema ();
            var7 = 0x80618007;
          }
          else
          {
            var26 = var2 + 8;
            strncpy (var26, var65, var64);
            ((int *) var2)[1] = 0;
            ((int *) var2)[0] = 0;
          label36:
            var37 = ((int *) var4)[3];
          label37:
            if(var37 == 0)
            {
              var43 = sub_063D0 (var26);
              var46 = sub_063A4 (var43);
              var49 = sub_063D0 (var26);
              var52 = sub_063AC (var49, (var46 + 0xFFFFFFFF));
              sub_06360 (var52, 0);
            }
            var38 = ((int *) var4)[411];
            signalSema ();
            var7 = var7;
          }
        }
      }
      else
      {
        var24 = ((int *) var3)[4];
        var25 = 0x00007FFF;
        var26 = var2 + 8;
        if(var24 == 0x00007FFF)
        {
          var23 = 0;
          goto label17;
        }
        else
        {
          ((int *) var2)[0] = var24;
          var27 = var26;
          var28 = ((int *) var3)[3];
          var29 = ((int *) var3)[11];
          var30 = var28 | var26;
          var31 = var30 & 3;
          ((int *) var2)[1] = var29;
          var32 = var28 + 0x00000800;
          if(var31 == 0)
          {
            while (1) {
              var55 = ((int *) var28)[0];
              var56 = ((int *) var28)[1];
              var57 = ((int *) var28)[2];
              var58 = ((int *) var28)[3];
              ((int *) var27)[0] = var55;
              var28 = var28 + 0x10;
              var27 = var27 + 0x10;
              ((int *) var27)[1073741821] = var56;
              ((int *) var27)[1073741822] = var57;
              ((int *) var27)[1073741823] = var58;
              if(var28 != var32)
                continue;
              break;
            }
            var37 = ((int *) var4)[3];
          }
          else
          {
            while (1) {
              var33 = LWL (var28, var30, 3);
              var30 = LWR (var28, var33, 0);
              var34 = LWL (var28, var31, 0x07);
              var31 = LWR (var28, var34, 4);
              var35 = LWL (var28, var25, 0x0B);
              var25 = LWR (var28, var35, 8);
              var36 = LWL (var28, var32, 0x0F);
              var32 = LWR (var28, var36, 0x0C);
              SWL (var27, var30, 3);
              SWR (var27, var30, 0);
              SWL (var27, var31, 0x07);
              SWR (var27, var31, 4);
              SWL (var27, var25, 0x0B);
              SWR (var27, var25, 8);
              SWL (var27, var32, 0x0F);
              SWR (var27, var32, 0x0C);
              var28 = var28 + 0x10;
              var27 = var27 + 0x10;
              if(var28 != var32)
                continue;
              break;
            }
            goto label36;
          }
          goto label37;
        }
      }
    }
  }
  ra = ((int *) sp)[22];
  var8 = ((int *) sp)[21];
  var9 = ((int *) sp)[20];
  var10 = ((int *) sp)[19];
  var11 = ((int *) sp)[18];
  var12 = ((int *) sp)[17];
  var13 = ((int *) sp)[16];
  sp = sp + 0x60;
  return var7;
}
int mpegChangeGetAvcAuMode (int arg1, int arg2, int arg3){
  sp = sp + 0xFFFFFFE0;
  ((int *) sp)[4] = s4;
  var1 = arg3;
  ((int *) sp)[2] = s2;
  var2 = arg2;
  ((int *) sp)[1] = s1;
  ((int *) sp)[0] = s0;
  ((int *) sp)[5] = ra;
  ((int *) sp)[3] = s3;
  var3 = ((int *) arg1)[0];
  var6 = checkMpegLib (arg1);
  var7 = var6;
  if(var6 == 0)
  {
    var13 = ((int *) var3)[411];
    waitSema ();
    var16 = ((int *) arg1)[0];
    var17 = ((int *) var2)[0];
    var20 = unRegistStream (var17, var16, 1);
    if(var20 == 0xFFFFFFFF)
    {
    label11:
      var28 = ((int *) var3)[411];
      signalSema ();
      var6 = 0x806101FE;
    }
    else
    {
      var21 = ((int *) var2)[2];
      if(var21 == 0xFFFFFFFF)
        goto label11;
      if(var1 == 0)
      {
        var27 = ((int *) var2)[12];
        var26 = (var27 & 0xFFFFFFFD) | (0 & 1);
      label20:
        ((int *) var2)[12] = var26;
      }
      else
      {
        if(var1 == 2)
        {
          var25 = ((int *) var2)[12];
          var26 = var25 | 2;
          goto label20;
        }
        else
        {
          var7 = 0x806101FE;
        }
      }
      var22 = ((int *) var3)[411];
      signalSema ();
      var6 = var7;
    }
  }
  ra = ((int *) sp)[5];
  var8 = ((int *) sp)[4];
  var9 = ((int *) sp)[3];
  var10 = ((int *) sp)[2];
  var11 = ((int *) sp)[1];
  var12 = ((int *) sp)[0];
  sp = sp + 0x20;
  return var6;
}
int mpegChangeGetAuMode (int arg1, int arg2, int arg3){
  sp = sp + 0xFFFFFFE0;
  ((int *) sp)[4] = s4;
  var1 = arg3;
  ((int *) sp)[2] = s2;
  var2 = arg2;
  ((int *) sp)[1] = s1;
  ((int *) sp)[0] = s0;
  ((int *) sp)[5] = ra;
  ((int *) sp)[3] = s3;
  var3 = ((int *) arg1)[0];
  var6 = checkMpegLib (arg1);
  var7 = var6;
  if(var6 == 0)
  {
    var13 = ((int *) var3)[411];
    waitSema ();
    var16 = ((int *) var2)[0];
    var17 = ((int *) arg1)[0];
    var20 = unRegistStream (var16, var17, 1);
    if(var20 == 0xFFFFFFFF)
    {
      var27 = ((int *) var3)[411];
      signalSema ();
      var6 = 0x806101FE;
    }
    else
    {
      if(var1 == 0)
      {
        var26 = ((int *) var2)[12];
        var25 = (var26 & 0xFFFFFFFE) | (0 & 1);
      label19:
        ((int *) var2)[12] = var25;
      }
      else
      {
        if(var1 == 1)
        {
          var24 = ((int *) var2)[12];
          var25 = var24 | 1;
          goto label19;
        }
        else
        {
          var7 = 0x806101FE;
        }
      }
      var21 = ((int *) var3)[411];
      signalSema ();
      var6 = var7;
    }
  }
  ra = ((int *) sp)[5];
  var8 = ((int *) sp)[4];
  var9 = ((int *) sp)[3];
  var10 = ((int *) sp)[2];
  var11 = ((int *) sp)[1];
  var12 = ((int *) sp)[0];
  sp = sp + 0x20;
  return var6;
}
void sceMpegQueryStreamOffset (int arg1, int arg2, int arg3){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
  return mpegQueryStreamOffset (arg1, arg2, arg3);
}
void sceMpegQueryStreamSize (int arg1, int arg2){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
  return mpegQueryStreamSize (arg1, arg2);
}
void sceMpegInit (){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
  return mpegInit ();
}
void sceMpegFinish (){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
  return mpegFinish ();
}
void sceMpegQueryMemSize (int arg1){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
#ifdef VSH
  return mpegQueryMemSize (arg1);
#else
#endif
}
void sceMpeg_42C679F6 (int arg1){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
  return mpegQueryMemSize (arg1);
}
void sceMpegCreate (int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7){
  if(checkThreadStack()>=0x3E0)return 0x80618008;
  return mpegCreate (arg1, arg2, arg3, arg4, arg5, arg6, arg7);
}
void sceMpeg_75E21135 (int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7){
  if(checkThreadStack()>=0x3E0)return 0x80618008;
  return mpegCreate (arg1, arg2, arg3, arg4, arg5, arg6, arg7);
}
void sceMpegDelete (int arg1){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
  return mpegDelete (arg1);
}
void sceMpegRegistStream (int arg1, int arg2, int arg3){
  if(checkThreadStack()>=0x3F0)return 0;
  return mpegRegistStream (arg1, arg2, arg3);
}
void sceMpegUnRegistStream (int arg1, int arg2){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
  return mpegUnRegistStream (arg1, arg2);
}
void sceMpegMallocAvcEsBuf (int arg1){
  if(checkThreadStack()>=0x3F0)return 0;
  return mpegMallocAvcEsBuf (arg1);
}
void sceMpegFreeAvcEsBuf (int arg1, int arg2){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
  return mpegFreeAvcEsBuf (arg1, arg2);
}
void sceMpegQueryAtracEsSize (int arg1, int arg2, int arg3){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
  return mpegQueryAtracEsSize (arg1, arg2, arg3);
}
void sceMpegQueryPcmEsSize (int arg1, int arg2, int arg3){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
  return mpegQueryPcmEsSize (arg1, arg2, arg3);
}
void sceMpegInitAu (int arg1, int arg2, int arg3){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
  return mpegInitAu (arg1, arg2, arg3);
}
void sceMpegChangeGetAvcAuMode (int arg1, int arg2, int arg3){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
  return mpegChangeGetAvcAuMode (arg1, arg2, arg3);
}
void sceMpegChangeGetAuMode (int arg1, int arg2, int arg3){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
  return mpegChangeGetAuMode (arg1, arg2, arg3);
}
void sceMpegNextAvcRpAu (int arg1, int arg2){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
  return mpegNextAvcRpAu (arg1, arg2);
}
void sceMpegGetAvcAu (int arg1, int arg2, int arg3, int arg4){
  if(checkThreadStack()>=0x3E0)return 0x80618008;
  return mpegGetAvcAu (arg1, arg2, arg3, arg4);
}
void sceMpegGetPcmAu (int arg1, int arg2, int arg3, int arg4){
  if(checkThreadStack()>=0x3E0)return 0x80618008;
  return mpegGetPcmAu (arg1, arg2, arg3, arg4);
}
void sceMpegGetAtracAu (int arg1, int arg2, int arg3, int arg4){
  if(checkThreadStack()>=0x3E0)return 0x80618008;
  return mpegGetAtracAu (arg1, arg2, arg3, arg4);
}
void sceMpegFlushStream (int arg1, int arg2){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
  return mpegFlushStream (arg1, arg2);
}
void sceMpegFlushAllStream (int arg1){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
  return mpegFlushAllStream (arg1);
}
void sceMpegAvcDecode (int arg1, int arg2, int arg3, int arg4, int arg5){
  if(checkThreadStack()>=0x3E0)return 0x80618008;
  return mpegAvcDecode (arg1, arg2, arg3, arg4, arg5);
}
void sceMpegAvcDecodeDetail (int arg1, int arg2){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
  return mpegAvcDecodeDetail (arg1, arg2);
}
void sceMpegAvcDecodeMode (int arg1, int arg2){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
  return mpegAvcDecodeMode (arg1, arg2);
}
void sceMpegAvcDecodeStop (int arg1, int arg2, int arg3, int arg4){
  if(checkThreadStack()>=0x3E0)return 0x80618008;
  return mpegAvcDecodeStop (arg1, arg2, arg3, arg4);
}
void sceMpegAvcDecodeFlush (int arg1){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
  return mpegAvcDecodeFlush (arg1);
}
void sceMpegAvcQueryYCbCrSize (int arg1, int arg2, int arg3, int arg4, int arg5){
  if(checkThreadStack()>=0x3E0)return 0x80618008;
  return mpegAvcQueryYCbCrSize (arg1, arg2, arg3, arg4, arg5);
}
void sceMpegAvcInitYCbCr (int arg1, int arg2, int arg3, int arg4, int arg5){
  if(checkThreadStack()>=0x3E0)return 0x80618008;
  return mpegAvcInitYCbCr (arg1, arg2, arg3, arg4, arg5);
}
void sceMpegAvcDecodeYCbCr (int arg1, int arg2, int arg3, int arg4){
  if(checkThreadStack()>=0x3E0)return 0x80618008;
  return mpegAvcDecodeYCbCr (arg1, arg2, arg3, arg4);
}
void sceMpegAvcDecodeStopYCbCr (int arg1, int arg2, int arg3){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
  return mpegAvcDecodeStopYCbCr (arg1, arg2, arg3);
}
void sceMpegAvcCsc (int arg1, int arg2, int arg3, int arg4, int arg5){
  if(checkThreadStack()>=0x3E0)return 0x80618008;
  return mpegAvcCsc (arg1, arg2, arg3, arg4, arg5);
}
void sceMpeg_0558B075 (int arg1, int arg2, int arg3){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
  return mpeg_0558B075 (arg1, arg2, arg3);
}
void sceMpegAtracDecode (int arg1, int arg2, int arg3, int arg4){
  if(checkThreadStack()>=0x3E0)return 0x80618008;
  return mpegAtracDecode (arg1, arg2, arg3, arg4);
  return 0x806101FE;
}
void sceMpegQueryUserdataEsSize (int arg1, int arg2, int arg3){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
  return mpegQueryUserdataEsSize (arg1, arg2, arg3);
}
void sceMpegQueryUserdataEsSize2 (int arg1, int arg2, int arg3, int arg4){//sceMpegQueryUserdataEsSize
  if(checkThreadStack()>=0x3E0)return 0x80618008;
  return mpegQueryUserdataEsSize2 (arg1, arg2, arg3, arg4);
}
void sceMpegGetAvcEsAu (int arg1, int arg2, int arg3, int arg4){
  if(checkThreadStack()>=0x3E0)return 0x80618008;
  return mpegGetAvcEsAu (arg1, arg2, arg3, arg4);
}
void sceMpegGetAvcNalAu (int arg1, int arg2, int arg3){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
  return mpegGetAvcNalAu (arg1, arg2, arg3);
}
void sceMpegRingbufferQueryMemSize (int arg1){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
  return mpegRingbufferQueryMemSize (arg1);
}
void sceMpegRingbufferQueryPackNum (int arg1){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
  return mpegRingbufferQueryPackNum (arg1);
}
void sceMpegRingbufferConstruct (int arg1, int arg2, int arg3, int arg4, int arg5, int arg6){
  if(checkThreadStack()>=0x3E0)return 0x80618008;
  return mpegRingbufferConstruct (arg1, arg2, arg3, arg4, arg5, arg6);
}
void sceMpegRingbufferDestruct (int arg1){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
  return mpegRingbufferDestruct ();
}
void sceMpegRingbufferPut (int arg1, int arg2, int arg3){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
  return mpegRingbufferPut (arg1, arg2, arg3);
}
void sceMpegRingbufferAvailableSize (int arg1){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
  return mpegRingbufferAvailableSize (arg1);
}
void sceMpeg_11CAB459 (int arg1, int arg2, int arg3){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
  return mpeg_11CAB459 (arg1, arg2, arg3);
}
void sceMpeg_C2F02CDD (int arg1, int arg2, int arg3, int arg4){
  if(checkThreadStack()>=0x3E0)return 0x80618008;
  return mpeg_C2F02CDD (arg1, arg2, arg3, arg4);
  return;
}
void mpeg_5AC68A41 (int arg1, int arg2, int arg3, int arg4){
  if(checkThreadStack()>=0x3E0)return 0x80618008;
  return sub_0445C (arg1, arg2, arg3, arg4);
}
void sceMpegFlushAu (int arg1, int arg2){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
  return mpegFlushAu (arg1, arg2);
}
void sceMpeg_B27711A8 (int arg1, int arg2, int arg3, int arg4){
  if(checkThreadStack()>=0x3E0)return 0x80618008;
  return mpeg_B27711A8 (arg1, arg2, arg3, arg4);
}
void sceMpeg_D4DD6E75 (int arg1, int arg2, int arg3, int arg4){
  if(checkThreadStack()>=0x3E0)return 0x80618008;
  return mpeg_D4DD6E75 (arg1, arg2, arg3, arg4);
}
void sceMpeg_C345DED2 (int arg1, int arg2){
  if(checkThreadStack()>=0x3F0)return 0;
  return mpeg_C345DED2 (arg1, arg2);
}
void sceMpeg_AB0E9556 (int arg1, int arg2, int arg3){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
  return avcDecodeDetail (arg1, arg2, arg3);
}
void sceMpegAvcDecodeDetail2 (int arg1, int arg2){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
  return mpegAvcDecodeDetail2 (arg1, arg2);
}
void sceMpegAvcDecodeGetDecodeSEI (int arg1, int arg2){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
  return mpegAvcDecodeGetDecodeSEI (arg1, arg2);
}
void sceMpeg_AE693D0B (int arg1, int arg2){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
  return mpeg_AE693D0B (arg1, arg2);
}
void sceMpegAvcCscMode (int arg1, int arg2){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
  return mpegAvcCscMode (arg1, arg2);
}
void sceMpeg_E49EB257 (int arg1){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
  return mpeg_E49EB257 (arg1);
}
void sceMpegAvcCscInfo (int arg1, int arg2, int arg3, int arg4){
  if(checkThreadStack()>=0x3E0)return 0x80618008;
  return mpegAvcCscInfo (arg1, arg2, arg3, arg4);
}
void sceMpeg_988E9E12 (int arg1, int arg2, int arg3){
  if(checkThreadStack()>=0x3F0)return 0x80618008;
  return mpeg_988E9E12 (arg1, arg2, arg3);
}
int createSema (int arg1, int arg2, int arg3, int arg4){
  arg4[0] = sceKernelCreateSema (arg3, 0, arg1, arg2, 0);
  return arg4[0]<0?0x80000041:0;
}
int deleteSema (){
  return sceKernelDeleteSema()?0x80000041:0;
}
void waitSema (){
  sceKernelWaitSema (arg1, 1, 0);
}
void signalSema (){
  sceKernelSignalSema (arg1, 1);
}
int checkThreadStack(){
  return sceKernelcheckThreadStack();
}
void initAudioCodec (){
  pVideoCodecStruct = &videoCodecStruct;
  memset (pVideoCodecStruct, 0, 0x60);
  *((int *) 0x0000A340) = 0;
  *((int *) 0x0000A344) = 0;
  *((int *) 0x0000A348) = 0;
  *((int *) 0x0000A34C) = 0;
  *((int *) 0x0000A350) = 0;
  *((int *) 0x0000A354) = 0;
  *((int *) 0x0000A358) = 0;
  *((int *) 0x0000A35C) = 0;
  *((int *) 0x0000A360) = 0;
  *((int *) 0x0000A364) = 0;
  pVideoCodecStruct[4] = 0x0000A340;
  *((int *) 0x0000A284) = pVideoCodecStruct[4];
  var7 = videocodecOpen (sp);
  var8 = var7;
  if(var7 == 0)
  {
    var10 = *((int *) pVideoCodecStruct);
    var13 = sceVideocodecGetEDRAM (var10, 0);
    var8 = 0;
    if(!(var13 == 0))
    {
      var14 = *((int *) pVideoCodecStruct);
      var8 = var13;
      ((int *) var14)[5] = 0;
    }
  }
  ra = ((int *) sp)[5];
  var9 = ((int *) sp)[4];
  sp = sp + 0x20;
  return;
}
int videocodecOpen (int arg1){
  ret = sceVideocodecOpen (pVideoCodecStruct, 0);
  *arg1 = pVideoCodecStruct[6];
  return ret;
}
int sub_083E4 (int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8){
  sp = sp + 0xFFFFFFD0;
  ((int *) sp)[5] = s5;
  ((int *) sp)[4] = s4;
  var1 = arg1;
  var2 = *((int *) mpegAvcSema);
  ((int *) sp)[0] = s0;
  var3 = arg2;
  ((int *) sp)[9] = ra;
  ((int *) sp)[8] = fp;
  ((int *) sp)[7] = s7;
  ((int *) sp)[6] = s6;
  ((int *) sp)[3] = s3;
  ((int *) sp)[2] = s2;
  var4 = arg4;
  ((int *) sp)[1] = s1;
  var5 = arg3;
  waitSema ();
  ((int *) var3)[0] = 0;
  ((int *) var3)[1] = 0;
  ((int *) var3)[2] = 0;
  ((int *) var3)[3] = 0;
  ((int *) var3)[4] = 0;
  ((int *) var3)[5] = 0;
  ((int *) var3)[6] = 0;
  ((int *) var3)[7] = 0;
  ((int *) var3)[8] = 0;
  ((int *) var3)[9] = 0;
  memset (var5, 0, 0xB0);
  memset (var4, 0, 0x64);
  ((int *) var1)[4] = var3;
  ((int *) var1)[11] = var5;
  ((int *) var1)[12] = var4;
  ((int *) var1)[15] = 4;
  ((int *) var1)[14] = arg5;
  var14 = sceVideocodecOpen (var1, 0);
  var15 = var14;
  if(var14 != 0)
  {
  label23:
    var29 = *((int *) mpegAvcSema);
    signalSema ();
    var32 = var15;
  }
  else
  {
    var16 = ((int *) arg6)[0];
    ((int *) var1)[7] = arg7;
    ((int *) var1)[5] = var16;
    var19 = sceVideocodecInit (var1, 0);
    var15 = var19;
    if(var19 != 0)
      goto label23;
    var22 = sceVideocodecGetVersion (var1, 0);
    var15 = var22;
    if(var22 != 0)
      goto label23;
    ((int *) var1)[16] = arg8;
    var23 = ((int *) sp)[12];
    ((int *) var1)[17] = var23;
    var24 = ((int *) sp)[13];
    ((int *) var1)[18] = var24;
    var25 = ((int *) sp)[14];
    ((int *) var1)[19] = var25;
    var28 = sceVideocodecSetMemory (var1, 0);
    var15 = var28;
    if(!(var28 == 0))
      goto label23;
    var42 = *((int *) mpegAvcSema);
    signalSema ();
    var32 = 0;
  }
  ra = ((int *) sp)[9];
  var33 = ((int *) sp)[8];
  var34 = ((int *) sp)[7];
  var35 = ((int *) sp)[6];
  var36 = ((int *) sp)[5];
  var37 = ((int *) sp)[4];
  var38 = ((int *) sp)[3];
  var39 = ((int *) sp)[2];
  var40 = ((int *) sp)[1];
  var41 = ((int *) sp)[0];
  sp = sp + 0x30;
  return var32;
}
void videocodecReleaseEDRAM (){
  var1 = *((int *) pVideoCodecStruct);
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[0] = ra;
  sceVideocodecReleaseEDRAM (var1);
  ra = ((int *) sp)[0];
  sp = sp + 0x10;
  return;
}
int sub_08588 (int arg1){
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[0] = s0;
  ((int *) sp)[1] = s1;
  var1 = *((int *) mpegAvcSema);
  ((int *) sp)[2] = ra;
  waitSema ();
  var6 = videocodecOpen (arg1);
  var7 = *((int *) mpegAvcSema);
  signalSema ();
  ra = ((int *) sp)[2];
  var10 = ((int *) sp)[1];
  var11 = ((int *) sp)[0];
  sp = sp + 0x10;
  return var6;
}
int sub_085D8 ()
{
  var1 = *((int *) pVideoCodecStruct);
  var2 = ((int *) var1)[5];
  return var2;
}
int sub_085E8 (int arg1){
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[0] = s0;
  ((int *) sp)[1] = s1;
  var1 = *((int *) mpegAvcSema);
  ((int *) sp)[2] = ra;
  waitSema ();
  var6 = sceVideocodecDecode (arg1, 0);
  var7 = *((int *) mpegAvcSema);
  signalSema ();
  ra = ((int *) sp)[2];
  var10 = ((int *) sp)[1];
  var11 = ((int *) sp)[0];
  sp = sp + 0x10;
  return var6;
}
int videocodecStop (int arg1){
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[0] = s0;
  ((int *) sp)[1] = s1;
  var1 = *((int *) mpegAvcSema);
  ((int *) sp)[2] = ra;
  waitSema ();
  var6 = sceVideocodecStop (arg1, 0);
  var7 = *((int *) mpegAvcSema);
  signalSema ();
  ra = ((int *) sp)[2];
  var10 = ((int *) sp)[1];
  var11 = ((int *) sp)[0];
  sp = sp + 0x10;
  return var6;
}
void delete (int arg1){
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[1] = s1;
  ((int *) sp)[0] = s0;
  var1 = *((int *) mpegAvcSema);
  ((int *) sp)[2] = ra;
  waitSema ();
  var6 = sceVideocodecDelete (arg1, 0);
  if(var6 == 0)
  {
    var12 = *((int *) mpegAvcSema);
    signalSema ();
  }
  else
  {
    var7 = *((int *) mpegAvcSema);
    signalSema ();
  }
  ra = ((int *) sp)[2];
  var10 = ((int *) sp)[1];
  var11 = ((int *) sp)[0];
  sp = sp + 0x10;
  return;
}
int sub_087B8 (int arg1, int arg2){
  waitSema (mpegAvcSema);
  arg1[22] = arg2;
  var7 = sceVideocodec_893B32B1 (arg1, 0);
  signalSema (mpegAvcSema);
  return var7;
}
int sub_086F8 (int arg1, int arg2){
  waitSema (mpegAvcSema);
  arg1[20] = arg2;
  var7 = sceVideocodec_893B32B1 (arg1, 0);
  signalSema (mpegAvcSema);
  return var7;
}
int sub_08758 (int arg1, int arg2){
  waitSema (mpegAvcSema);
  arg1[21] = arg2;
  var7 = sceVideocodec_893B32B1 (arg1, 0);
  signalSema (mpegAvcSema);
  return var7;
}
int sub_08818 (int arg1, int arg2, int arg3, int arg4){
  sp = sp + 0xFFFFFFD0;
  ((int *) sp)[10] = s6;
  ((int *) sp)[7] = s3;
  var1 = arg4;
  ((int *) sp)[5] = s1;
  var2 = arg1;
  ((int *) sp)[4] = s0;
  var3 = arg3;
  ((int *) sp)[11] = ra;
  ((int *) sp)[9] = s5;
  ((int *) sp)[8] = s4;
  ((int *) sp)[6] = s2;
  var4 = *((int *) mpegAvcSema);
  var5 = ((int *) arg2)[12];
  var6 = ((int *) arg2)[4];
  waitSema ();
  var9 = ((unsigned char *) var3)[0];
  if(!((var9 & 2) == 0))
  {
    var10 = ((int *) var3)[6];
    var11 = ((int *) var2)[2];
    var12 = ((int *) var2)[0];
    var13 = var10 + var11;
    ((int *) var2)[1] = var13;
    var14 = ((int *) var3)[7];
    var15 = var13 + var14;
    if((var12 & 2) == 0)
    {
    label12:
      var18 = ((unsigned char *) var3)[0];
    }
    else
    {
      var16 = ((int *) var2)[3];
      if(((var15 < var16)) == 0)
      {
        var17 = ((int *) var6)[8];
      }
      else
      {
        ((int *) var2)[3] = var15;
        ((int *) var2)[4] = var15;
        var17 = ((int *) var6)[8];
      }
      if(var17 == 0)
      {
        var18 = ((unsigned char *) var3)[0];
      }
      else
      {
        ((int *) var2)[0] = ((var12 & 0xFFFFFFFD) | (0 & 1));
        goto label12;
      }
    }
    var19 = var2 + 0x14;
    if((var18 & 1) != 0)
    {
      var32 = sub_09554 (var19);
      if(var32 <= 0)
      {
        sub_093B8 (var19, 1);
        var33 = ((int *) var6)[9];
      }
      else
      {
        var33 = ((int *) var6)[9];
      }
      if(var33 == 1)
      {
        var35 = sp;
        sub_094A0 (var19, 0, var35);
        var38 = ((int *) var1)[0];
        var39 = ((int *) sp)[0];
        var40 = var6;
        ((int *) var6)[4] = var38;
        var41 = var39;
        var42 = ((int *) var1)[1];
        ((int *) var6)[5] = var42;
        var43 = ((int *) var1)[2];
        ((int *) var6)[6] = var43;
        var44 = ((int *) var1)[3];
        ((int *) var6)[7] = var44;
        while (1) {
          var45 = ((int *) var40)[0];
          var46 = ((int *) var40)[1];
          var47 = ((int *) var40)[2];
          var48 = ((int *) var40)[3];
          ((int *) var41)[0] = var45;
          var40 = var40 + 0x10;
          var41 = var41 + 0x10;
          ((int *) var41)[1073741821] = var46;
          ((int *) var41)[1073741822] = var47;
          ((int *) var41)[1073741823] = var48;
          if(var40 != (var6 + 0x20))
            continue;
          break;
        }
        var49 = ((int *) var40)[0];
        var50 = ((int *) var40)[1];
        ((int *) var41)[0] = var49;
        ((int *) var41)[1] = var50;
        var51 = var39 + 0x28;
        var52 = var5;
        while (1) {
          var53 = ((int *) var52)[0];
          var54 = ((int *) var52)[1];
          var55 = ((int *) var52)[2];
          var56 = ((int *) var52)[3];
          ((int *) var51)[0] = var53;
          var52 = var52 + 0x10;
          var51 = var51 + 0x10;
          ((int *) var51)[1073741821] = var54;
          ((int *) var51)[1073741822] = var55;
          ((int *) var51)[1073741823] = var56;
          if(var52 != (var5 + 0x60))
            continue;
          break;
        }
        var57 = ((int *) var52)[0];
        ((int *) var51)[0] = var57;
        ((int *) var39)[35] = var15;
        var60 = sub_09554 (var19);
        sub_09414 (var19, 1, var60);
        var34 = ((int *) var2)[1];
      }
      else
      {
        var34 = ((int *) var2)[1];
      }
      ((int *) var2)[2] = var34;
    }
  }
  var20 = *((int *) mpegAvcSema);
  signalSema ();
  ra = ((int *) sp)[11];
  var23 = ((int *) sp)[10];
  var24 = ((int *) sp)[9];
  var25 = ((int *) sp)[8];
  var26 = ((int *) sp)[7];
  var27 = ((int *) sp)[6];
  var28 = ((int *) sp)[5];
  var29 = ((int *) sp)[4];
  sp = sp + 0x30;
  return 0;
}
int sub_08A18 (int arg1, int arg2){
  sp = sp + 0xFFFFFFB0;
  ((int *) sp)[13] = s5;
  var1 = arg1;
  ((int *) sp)[10] = s2;
  var2 = arg2;
  ((int *) sp)[17] = ra;
  ((int *) sp)[16] = fp;
  ((int *) sp)[15] = s7;
  ((int *) sp)[14] = s6;
  ((int *) sp)[12] = s4;
  ((int *) sp)[11] = s3;
  ((int *) sp)[9] = s1;
  ((int *) sp)[8] = s0;
  var3 = *((int *) mpegAvcSema);
  var4 = ((int *) arg2)[4];
  waitSema ();
  var7 = ((int *) var4)[8];
  var8 = var1 + 0x2C;
  var9 = var2;
  ((int *) sp)[1] = var7;
  while (1) {
    var10 = ((int *) var9)[0];
    var11 = ((int *) var9)[1];
    var12 = ((int *) var9)[2];
    var13 = ((int *) var9)[3];
    ((int *) var8)[0] = var10;
    var9 = var9 + 0x10;
    var8 = var8 + 0x10;
    ((int *) var8)[1073741821] = var11;
    ((int *) var8)[1073741822] = var12;
    ((int *) var8)[1073741823] = var13;
    if(var9 != (var2 + 0x60))
      continue;
    break;
  }
  var14 = ((int *) sp)[1];
  if(!(var14 <= 0))
  {
    ((int *) sp)[3] = (var1 + 0x8C);
    var15 = var1 + 0x0000012C;
    var16 = var1;
    ((int *) sp)[4] = 0;
    var17 = var1;
    var18 = var15;
    var19 = var14;
    while (1) {
      var20 = ((int *) var2)[14];
      var21 = ((int *) sp)[4];
      ((int *) sp)[2] = 0xFFFFFFFF;
      var22 = var20 + var21;
      var23 = ((unsigned char *) var22)[0];
      var24 = ((int *) sp)[2];
      if(!((var23 & 2) == 0))
      {
        var25 = ((unsigned char *) var22)[32];
        ((int *) sp)[2] = var25;
        var24 = ((int *) sp)[2];
      }
      var26 = var1 + 0x14;
      if(((var24 < 0x07)) != 0)
      {
        var71 = sub_0948C (var26);
        if(var71 != 0)
        {
          var27 = ((int *) var2)[21];
        label47:
          var28 = var4;
          var29 = var16 + 0x8C;
          var30 = ((int *) var27)[0];
          ((int *) var4)[4] = var30;
          var31 = ((int *) var27)[1];
          ((int *) var4)[5] = var31;
          var32 = ((int *) var27)[2];
          ((int *) var4)[6] = var32;
          var33 = ((int *) var27)[3];
          ((int *) var4)[7] = var33;
          while (1) {
            var34 = ((int *) var28)[0];
            var35 = ((int *) var28)[1];
            var36 = ((int *) var28)[2];
            var37 = ((int *) var28)[3];
            ((int *) var29)[0] = var34;
            var28 = var28 + 0x10;
            var29 = var29 + 0x10;
            ((int *) var29)[1073741821] = var35;
            ((int *) var29)[1073741822] = var36;
            ((int *) var29)[1073741823] = var37;
            if(var28 != (var4 + 0x20))
              continue;
            break;
          }
          var38 = ((int *) var28)[0];
          var39 = ((int *) var28)[1];
          ((int *) var29)[0] = var38;
          ((int *) var29)[1] = var39;
          var40 = var18;
          var41 = ((int *) var2)[12];
          var42 = var41 + 0x60;
          if(((var41 | var18) & 3) == 0)
          {
            while (1) {
              var64 = ((int *) var41)[0];
              var65 = ((int *) var41)[1];
              var66 = ((int *) var41)[2];
              var67 = ((int *) var41)[3];
              ((int *) var40)[0] = var64;
              var41 = var41 + 0x10;
              var40 = var40 + 0x10;
              ((int *) var40)[1073741821] = var65;
              ((int *) var40)[1073741822] = var66;
              ((int *) var40)[1073741823] = var67;
              if(var41 != var42)
                continue;
              break;
            }
            var68 = ((int *) var41)[0];
            ((int *) var40)[0] = var68;
            var50 = ((int *) sp)[4];
          }
          else
          {
            var43 = var42;
            while (1) {
              var44 = LWL (var41, var31, 3);
              var31 = LWR (var41, var44, 0);
              var45 = LWL (var41, var38, 0x07);
              var38 = LWR (var41, var45, 4);
              var46 = LWL (var41, var39, 0x0B);
              var39 = LWR (var41, var46, 8);
              var47 = LWL (var41, var42, 0x0F);
              var42 = LWR (var41, var47, 0x0C);
              SWL (var40, var31, 3);
              SWR (var40, var31, 0);
              SWL (var40, var38, 0x07);
              SWR (var40, var38, 4);
              SWL (var40, var39, 0x0B);
              SWR (var40, var39, 8);
              SWL (var40, var42, 0x0F);
              SWR (var40, var42, 0x0C);
              var41 = var41 + 0x10;
              var40 = var40 + 0x10;
              if(var41 != var43)
                continue;
              break;
            }
            var48 = LWL (var41, var43, 3);
            var49 = LWR (var41, var48, 0);
            SWL (var40, var49, 3);
            SWR (var40, var49, 0);
          label55:
            var50 = ((int *) sp)[4];
          }
        }
        else
        {
          var72 = sp;
          sub_094F4 (var26, 1, var72);
          var75 = ((int *) sp)[0];
          var76 = sp;
          if(!(var75 == 0))
          {
            var77 = ((int *) var75)[35];
            var78 = ((int *) var1)[4];
            if(((var78 < var77)) == 0)
            {
              sub_093B8 (var26, 1);
              var136 = ((int *) var1)[0];
              ((int *) var1)[0] = (var136 | 4);
            }
            var76 = sp;
          }
          sub_094F4 (var26, 0, var76);
          var81 = ((int *) sp)[0];
          var82 = var16 + 0x8C;
          var83 = var81;
          if(var81 == 0)
          {
            var103 = ((int *) var2)[4];
            var104 = ((int *) sp)[3];
            var105 = (var103 | var104) & 3;
            var106 = var103 + 0x20;
            if(var105 == 0)
            {
              while (1) {
                var130 = ((int *) var103)[0];
                var131 = ((int *) var103)[1];
                var132 = ((int *) var103)[2];
                var133 = ((int *) var103)[3];
                ((int *) var104)[0] = var130;
                var103 = var103 + 0x10;
                var104 = var104 + 0x10;
                ((int *) var104)[1073741821] = var131;
                ((int *) var104)[1073741822] = var132;
                ((int *) var104)[1073741823] = var133;
                if(var103 != var106)
                  continue;
                break;
              }
              a0/* Invalid block 28 3 */ = ((int *) var103)[0];
              var112 = ((int *) var103)[1];
              ((int *) var104)[0] = a0/* Invalid block 28 3 */;
              ((int *) var104)[1] = var112;
              var115 = ((int *) var2)[12];
            }
            else
            {
              while (1) {
                var107 = LWL (var103);
                a1/* Invalid block 30 3 */ = LWR (var103, var107, 0);
                var108 = LWL (var103, var106, 0x07);
                var106 = LWR (var103, var108, 4);
                var109 = LWL (var103, var105, 0x0B);
                var105 = LWR (var103, var109, 8);
                var110 = LWL (var103);
                a0/* Invalid block 30 3 */ = LWR (var103, var110, 0x0C);
                SWL (var104);
                SWR (var104);
                SWL (var104, var106, 0x07);
                SWR (var104, var106, 4);
                SWL (var104, var105, 0x0B);
                SWR (var104, var105, 8);
                SWL (var104);
                SWR (var104);
                var103 = var103 + 0x10;
                var104 = var104 + 0x10;
                if(var103 != var106)
                  continue;
                break;
              }
              var111 = LWL (var103);
              var112 = LWR (var103, var111, 0);
              var113 = LWL (var103, var106, 0x07);
              var114 = LWR (var103, var113, 4);
              SWL (var104, var112, 3);
              SWR (var104, var112, 0);
              SWL (var104, var114, 0x07);
              SWR (var104, var114, 4);
              var115 = ((int *) var2)[12];
            }
            var116 = var15;
            var117 = var115 + 0x60;
            if(((var115 | var15) & 3) == 0)
            {
              while (1) {
                var125 = ((int *) var115)[0];
                var126 = ((int *) var115)[1];
                var127 = ((int *) var115)[2];
                var128 = ((int *) var115)[3];
                ((int *) var116)[0] = var125;
                var115 = var115 + 0x10;
                var116 = var116 + 0x10;
                ((int *) var116)[1073741821] = var126;
                ((int *) var116)[1073741822] = var127;
                ((int *) var116)[1073741823] = var128;
                if(var115 != var117)
                  continue;
                break;
              }
              var129 = ((int *) var115)[0];
              ((int *) var116)[0] = var129;
              var97 = ((int *) sp)[1];
            }
            else
            {
              var118 = var117;
              while (1) {
                var119 = LWL (var115, var105, 3);
                var105 = LWR (var115, var119, 0);
                var120 = LWL (var115);
                a0/* Invalid block 36 3 */ = LWR (var115, var120, 4);
                var121 = LWL (var115, var112, 0x0B);
                var112 = LWR (var115, var121, 8);
                var122 = LWL (var115, var117, 0x0F);
                var117 = LWR (var115, var122, 0x0C);
                SWL (var116, var105, 3);
                SWR (var116, var105, 0);
                SWL (var116);
                SWR (var116);
                SWL (var116, var112, 0x0B);
                SWR (var116, var112, 8);
                SWL (var116, var117, 0x0F);
                SWR (var116, var117, 0x0C);
                var115 = var115 + 0x10;
                var116 = var116 + 0x10;
                if(var115 != var118)
                  continue;
                break;
              }
              var123 = LWL (var115, var118, 3);
              var124 = LWR (var115, var123, 0);
              SWL (var116, var124, 3);
              SWR (var116, var124, 0);
              var97 = ((int *) sp)[1];
            }
          }
          else
          {
            while (1) {
              var84 = ((int *) var83)[0];
              var85 = ((int *) var83)[1];
              var86 = ((int *) var83)[2];
              var87 = ((int *) var83)[3];
              ((int *) var82)[0] = var84;
              var83 = var83 + 0x10;
              var82 = var82 + 0x10;
              ((int *) var82)[1073741821] = var85;
              ((int *) var82)[1073741822] = var86;
              ((int *) var82)[1073741823] = var87;
              if(var83 != (var81 + 0x20))
                continue;
              break;
            }
            var88 = ((int *) var83)[0];
            var89 = ((int *) var83)[1];
            ((int *) var82)[0] = var88;
            ((int *) var82)[1] = var89;
            var90 = var17 + 0x0000012C;
            var91 = var81 + 0x28;
            while (1) {
              var92 = ((int *) var91)[0];
              var93 = ((int *) var91)[1];
              var94 = ((int *) var91)[2];
              var95 = ((int *) var91)[3];
              ((int *) var90)[0] = var92;
              var91 = var91 + 0x10;
              var90 = var90 + 0x10;
              ((int *) var90)[1073741821] = var93;
              ((int *) var90)[1073741822] = var94;
              ((int *) var90)[1073741823] = var95;
              if(var91 != (var81 + 0x88))
                continue;
              break;
            }
            var96 = ((int *) var91)[0];
            ((int *) var90)[0] = var96;
            var97 = ((int *) sp)[1];
          }
          ((int *) var16)[43] = var97;
          var98 = ((int *) var1)[0];
          if((var98 & 4) == 0)
          {
            ((int *) var16)[44] = 0;
          }
          else
          {
            ((int *) var16)[44] = 1;
            var99 = ((int *) var1)[0];
            ((int *) var1)[0] = ((var99 & 0xFFFFFFFB) | (0 & 1));
          }
          var100 = ((int *) sp)[2];
          var101 = ((int *) var1)[4];
          var102 = ((unsigned char *) (var100 + 0x0000A18C))[0];
          ((int *) var1)[4] = (var101 + var102);
          goto label55;
        }
      }
      else
      {
        var27 = ((int *) var2)[21];
        goto label47;
      }
      var51 = ((int *) sp)[3];
      var19 = var19 + 0xFFFFFFFF;
      ((int *) sp)[4] = (var50 + 0x00000148);
      var18 = var18 + 0x64;
      var15 = var15 + 0x64;
      ((int *) sp)[3] = (var51 + 0x28);
      var17 = var17 + 0x64;
      var16 = var16 + 0x28;
      if(var19 != 0)
        continue;
      break;
    }
  }
  ((int *) var1)[23] = (var1 + 0x0000012C);
  ((int *) var1)[15] = (var1 + 0x8C);
  var52 = *((int *) mpegAvcSema);
  signalSema ();
  ra = ((int *) sp)[17];
  var55 = ((int *) sp)[16];
  var56 = ((int *) sp)[15];
  var57 = ((int *) sp)[14];
  var58 = ((int *) sp)[13];
  var59 = ((int *) sp)[12];
  var60 = ((int *) sp)[11];
  var61 = ((int *) sp)[10];
  var62 = ((int *) sp)[9];
  var63 = ((int *) sp)[8];
  sp = sp + 0x50;
  return 0;
}
int sub_08F70 (){
  return 0x0000058C;
}
void sub_08F78 (int arg1, int arg2){
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[2] = s2;
  ((int *) sp)[1] = s1;
  var1 = *((int *) mpegAvcSema);
  ((int *) sp)[0] = s0;
  ((int *) sp)[3] = ra;
  var2 = arg2;
  waitSema ();
  ((int *) arg1)[0] = var2;
  sub_09470 ((var2 + 0x14), 0x90, 0x05, (var2 + 0x000002BC));
  var7 = *((int *) mpegAvcSema);
  signalSema ();
  ra = ((int *) sp)[3];
  var10 = ((int *) sp)[2];
  var11 = ((int *) sp)[1];
  var12 = ((int *) sp)[0];
  sp = sp + 0x10;
  return;
}
void sub_08FE0 (int arg1){
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[2] = s2;
  ((int *) sp)[0] = s0;
  var1 = arg1;
  var2 = *((int *) mpegAvcSema);
  ((int *) sp)[1] = s1;
  ((int *) sp)[3] = ra;
  var3 = var1 + 0x14;
  waitSema ();
  var8 = sub_09498 (var3);
  sub_093B8 (var3, var8);
  ((int *) var1)[4] = 0xFFFFFFFF;
  ((int *) var1)[0] = 0x07;
  ((int *) var1)[3] = 0xFFFFFFFF;
  ((int *) var1)[1] = 0;
  var11 = *((int *) mpegAvcSema);
  ((int *) var1)[2] = 0;
  signalSema ();
  ra = ((int *) sp)[3];
  var14 = ((int *) sp)[2];
  var15 = ((int *) sp)[1];
  var16 = ((int *) sp)[0];
  sp = sp + 0x10;
  return;
}
int initVideoCodec (int arg1){
  sp = sp + 0xFFFFFFE0;
  ((int *) sp)[5] = s1;
  ((int *) sp)[4] = s0;
  ((int *) sp)[6] = ra;
  *((int *) pAudioCodecStruct) = &audioCodecStruct;
  memset (audioCodecStruct, 0, 0x6C);
  var3 = sp;
  var6 = audiocodecCheckNeedMem (var3, arg1, 0x0000A440);
  var7 = var6;
  if(var6 == 0)
  {
    var10 = *((int *) pAudioCodecStruct);
    var13 = sceAudiocodecGetEDRAM (var10, 0x00001000);
    var7 = 0;
    if(!(var13 == 0))
    {
      var14 = *((int *) pAudioCodecStruct);
      var7 = var13;
      ((int *) var14)[3] = 0;
    }
  }
  ra = ((int *) sp)[6];
  var8 = ((int *) sp)[5];
  var9 = ((int *) sp)[4];
  sp = sp + 0x20;
  return var7;
}
int audiocodecCheckNeedMem (int arg1, int arg2, int arg3){
  sp = sp + 0xFFFFFFF0;
  var1 = ((arg2 ^ 3) < 1);
  ((int *) sp)[1] = s1;
  ((int *) sp)[0] = s0;
  ((int *) sp)[2] = ra;
  var2 = *((int *) pAudioCodecStruct);
  var3 = (var1 << 1) + "(\\\";
  var4 = (var1 << 2) + 0x0000A198;
  if(!(arg3 == 0))
  {
    ((int *) arg3)[0] = var1;
  }
  ((int *) var2)[12] = 1;
  var5 = *((int *) pAudioCodecStruct);
  var6 = ((char *) var3)[0];
  var7 = ((char *) var3)[1];
  ((char *) var5)[40] = var6;
  ((char *) var5)[41] = var7;
  var8 = *((int *) pAudioCodecStruct);
  var9 = LWL (var4, v0, 3);
  var10 = LWR (var4, var9, 0);
  SWL (var8, var10, 0x2F);
  SWR (var8, var10, 0x2C);
  var11 = *((int *) pAudioCodecStruct);
  ((int *) var11)[5] = 1;
  var14 = sceAudiocodecCheckNeedMem (var11, 0x00001000);
  var15 = *((int *) pAudioCodecStruct);
  ra = ((int *) sp)[2];
  var16 = ((int *) sp)[0];
  var17 = ((int *) var15)[4];
  ((int *) arg1)[0] = var17;
  var18 = ((int *) sp)[1];
  sp = sp + 0x10;
  return var14;
}
int audiocodecSetup (int arg1, int arg2, int arg3, int arg4, int arg5){
  sp = sp + 0xFFFFFFE0;
  ((int *) sp)[4] = s4;
  ((int *) sp)[3] = s3;
  var1 = arg1;
  var2 = *((int *) mpegAtracSema);
  ((int *) sp)[6] = ra;
  ((int *) sp)[5] = s5;
  ((int *) sp)[2] = s2;
  var3 = arg5;
  ((int *) sp)[1] = s1;
  var4 = arg4;
  ((int *) sp)[0] = s0;
  waitSema ();
  ((int *) var1)[3] = arg2;
  ((int *) var1)[12] = 1;
  ((int *) var1)[14] = 1;
  var7 = ((char *) var4)[0];
  var8 = ((char *) var4)[1];
  ((char *) var1)[40] = var7;
  ((char *) var1)[41] = var8;
  var9 = LWL (var3, var7, 3);
  var10 = LWR (var3, var9, 0);
  SWL (var1, var10, 0x2F);
  SWR (var1, var10, 0x2C);
  ((int *) var1)[5] = 1;
  var13 = sceAudiocodecCheckNeedMem (var1, 0x00001000);
  var14 = var13;
  if(var13 != 0)
  {
  label14:
    var29 = *((int *) mpegAtracSema);
    signalSema ();
    var19 = var14;
  }
  else
  {
    var15 = ((int *) var1)[4];
    if(((arg3 < var15)) == 0)
    {
      var28 = sceAudiocodecInit (var1, 0x00001000);
      var14 = var28;
      if(!(var28 == 0))
        goto label14;
      var32 = *((int *) mpegAtracSema);
      signalSema ();
      var19 = 0;
    }
    else
    {
      var16 = *((int *) mpegAtracSema);
      signalSema ();
      var19 = 0x807F00FF;
    }
  }
  ra = ((int *) sp)[6];
  var20 = ((int *) sp)[5];
  var21 = ((int *) sp)[4];
  var22 = ((int *) sp)[3];
  var23 = ((int *) sp)[2];
  var24 = ((int *) sp)[1];
  var25 = ((int *) sp)[0];
  sp = sp + 0x20;
  return var19;
}
void audiocodecReleaseEDRAM (){
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[0] = ra;
  var1 = *((int *) pAudioCodecStruct);
  var2 = ((int *) var1)[3];
  if(var2 != 0)
  {
    sceAudiocodecReleaseEDRAM ();
    ra = ((int *) sp)[0];
  }
  else
  {
    ra = ((int *) sp)[0];
  }
  sp = sp + 0x10;
  return;
}
int sub_092D0 (int arg1, int arg2){
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[2] = s2;
  ((int *) sp)[1] = s1;
  var1 = *((int *) mpegAtracSema);
  ((int *) sp)[0] = s0;
  ((int *) sp)[3] = ra;
  waitSema ();
  var6 = audiocodecCheckNeedMem (arg1, arg2, 0);
  var7 = *((int *) mpegAtracSema);
  signalSema ();
  ra = ((int *) sp)[3];
  var10 = ((int *) sp)[2];
  var11 = ((int *) sp)[1];
  var12 = ((int *) sp)[0];
  sp = sp + 0x10;
  return var6;
}
int sub_09330 (int arg1){
  var1 = *((int *) pAudioCodecStruct);
  if(!(arg1 == 0))
  {
    var2 = *((int *) 0x0000A440);
    ((int *) arg1)[0] = var2;
  }
  var3 = ((int *) var1)[3];
  return var3;
}
int audiocodecDecode (int arg1){
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[1] = s1;
  ((int *) sp)[0] = s0;
  var1 = *((int *) mpegAtracSema);
  ((int *) sp)[2] = ra;
  waitSema ();
  var6 = sceAudiocodecDecode (arg1, 0x00001000);
  if(var6 == 0)
  {
    var13 = *((int *) mpegAtracSema);
    signalSema ();
    var10 = 0;
  }
  else
  {
    var7 = *((int *) mpegAtracSema);
    signalSema ();
    var10 = var6;
  }
  ra = ((int *) sp)[2];
  var11 = ((int *) sp)[1];
  var12 = ((int *) sp)[0];
  sp = sp + 0x10;
  return var10;
}
void sub_093B8 (int arg1, int arg2){
  var1 = ((int *) arg1)[3];
  var2 = arg1;
  var3 = MIN (arg2, var1);
  var4 = var3;
  if(!(var3 <= 0))
  {
    var5 = ((int *) arg1)[0];
    var6 = ((int *) var2)[1];
    while (1) {
      var7 = !(((var5 < (var6 + var4)))) ? var4 : (var5 - var6);
      var8 = var6 + var7;
      var4 = var4 - var7;
      ((int *) var2)[1] = var8;
      if(var8 == var5)
      {
        ((int *) var2)[1] = 0;
      }
      if(!(var4 > 0))
        break;
      var6 = ((int *) var2)[1];
      continue;
    }
  }
  ((int *) var2)[3] = (var1 - var3);
  return;
}
void sub_09414 (int arg1, int arg2, int arg3){
  var1 = MIN (arg2, arg3);
  var2 = arg1;
  var3 = var1;
  if(!(var1 <= 0))
  {
    var4 = ((int *) arg1)[0];
    var5 = ((int *) var2)[2];
    while (1) {
      var6 = !(((var4 < (var5 + var3)))) ? var3 : (var4 - var5);
      var7 = var5 + var6;
      var3 = var3 - var6;
      ((int *) var2)[2] = var7;
      if(var7 == var4)
      {
        ((int *) var2)[2] = 0;
      }
      if(!(var3 > 0))
        break;
      var5 = ((int *) var2)[2];
      continue;
    }
  }
  var8 = ((int *) var2)[3];
  ((int *) var2)[3] = (var8 + var1);
  return;
}
void sub_09470 (int arg1, int arg2, int arg3, int arg4){
  ((int *) arg1)[4] = arg4;
  ((int *) arg1)[5] = arg2;
  ((int *) arg1)[0] = arg3;
  ((int *) arg1)[1] = 0;
  ((int *) arg1)[3] = 0;
  ((int *) arg1)[2] = 0;
  return;
}
int sub_0948C (int arg1){
  var1 = ((int *) arg1)[3];
  return ((var1 < 1));
}
int sub_09498 (int arg1){
  var1 = ((int *) arg1)[3];
  return var1;
}
void sub_094A0 (int arg1, int arg2, int arg3){
  var1 = 0xFFFFFFFF;
  if(arg2 < 0)
  {
    ((int *) arg3)[0] = 0;
  }
  else
  {
    var2 = ((int *) arg1)[2];
    var3 = ((int *) arg1)[0];
    var1 = 0;
    if(var3 == 0)
    {
      __asm__ ("break      0x00007;");
    }
    var4 = ((int *) arg1)[5];
    var5 = ((int *) arg1)[4];
    ((int *) arg3)[0] = (var5 + (var4 * ((arg2 + var2) % var3)));
  }
  return;
}
void sub_094F4 (int arg1, int arg2, int arg3){
  var1 = 0xFFFFFFFF;
  var2 = arg1;
  if(arg2 < 0)
  {
  label8:
    ((int *) arg3)[0] = 0;
  }
  else
  {
    var3 = ((int *) arg1)[3];
    if(!(((arg2 < var3)) != 0))
      goto label8;
    var4 = ((int *) var2)[1];
    var5 = ((int *) var2)[0];
    var1 = 0;
    if(var5 == 0)
    {
      __asm__ ("break      0x00007;");
    }
    var6 = ((int *) var2)[5];
    var7 = ((int *) var2)[4];
    ((int *) arg3)[0] = (var7 + (var6 * ((arg2 + var4) % var5)));
  }
  return;
}
int sub_09554 (int arg1){
  var1 = ((int *) arg1)[3];
  var2 = ((int *) arg1)[0];
  return (var2 - var1);
}
int strncmp (int arg1, int arg2, int arg3){
  if(arg3 <= 0)
  {
    var3 = 0;
  }
  else
  {
    var1 = ((unsigned char *) arg1)[0];
    while (1) {
      var2 = ((unsigned char *) arg2)[0];
      arg3 = arg3 + 0xFFFFFFFF;
      arg1 = arg1 + 1;
      arg2 = arg2 + 1;
      if(var1 != var2)
        break;
      if(arg3 > 0)
      {
        var1 = ((unsigned char *) arg1)[0];
        continue;
      }
      else
      {
        var3 = 0;
      }
      goto label10;
    }
    var3 = !(((var1 < var2))) ? 1 : 0xFFFFFFFF;
  }
label10:
  return var3;
}
void strncpy (char*arg1, char*arg2, int arg3){
  if(!arg1)return;
	while(arg3<=0){
		arg1[0] = arg2[0];
		arg3--;
		arg2++;
		arg1++;
  }
}
void memset (int arg1, int arg2, int arg3){
  if(!(arg1 == 0))
  {
    var1 = arg1;
    if(!(arg3 <= 0))
    {
      while (1) {
        arg3 = arg3 + 0xFFFFFFFF;
        ((char *) var1)[0] = (arg2 & 0xFF);
        var1 = var1 + 1;
        if(arg3 > 0)
          continue;
        break;
      }
    }
  }
  return;
}
int strcmp (int arg1, int arg2){
  if((((arg1 < 1)) | ((arg2 < 1))) == 0)
  {
    var2 = ((unsigned char *) arg1)[0];
    var3 = ((char *) arg2)[0];
    var4 = (char) var2;
    var5 = arg2 + 1;
    if(var4 == var3)
    {
      var7 = var4;
      while (1) {
        arg1 = arg1 + 1;
        var1 = 0;
        if(var7 == 0)
          break;
        var2 = ((unsigned char *) arg1)[0];
        var8 = ((char *) var5)[0];
        var5 = var5 + 1;
        var9 = (char) var2;
        var7 = var9;
        if(var9 == var8)
          continue;
        var6 = ((char *) var5)[-1];
      label10:
        var1 = ((char) var2) - var6;
        goto label13;
      }
    }
    else
    {
      var6 = ((char *) var5)[-1];
      goto label10;
    }
  }
  else
  {
    var1 = 0;
    if(!(arg1 == arg2))
    {
      var1 = (arg1) ? 1 : 0xFFFFFFFF;
    }
  }
label13:
  return var1;
}
int abs (int arg1){
  return MAX(arg1,-arg1);
}
int getStream (int arg1, int arg2){
  var1 = 0x806101FE;
  var2 = 0;
  if(!(((arg1 < 0x13)) == 0))
  {
    var3 = arg1 << 3;
    var4 = ((int *) (var3 + stream))[1];
    if(var4 == 0xFFFF0000)
    {
      var2 = 0x10;
    label13:
    label14:
      var5 = ((int *) (var3 + stream))[0];
      var1 = var5 | (arg2 << var2);
    }
    else
    {
      if(((0xFFFF0000 < var4)) != 0)
      {
        if(var4 == 0xFFFFFF00)
        {
          var2 = 8;
          goto label13;
        }
        else
        {
          if(var4 != 0xFFFFFFFF)
          {
            var1 = 0;
          }
          else
          {
            goto label14;
          }
        }
      }
      else
      {
        if(var4 == 0xFF000000)
        {
          var2 = 0x18;
          goto label13;
        }
        else
        {
          var1 = 0;
        }
      }
    }
  }
  return var1;
}
void flushStream (int arg1, int arg2, int arg3){
  sp = sp + 0xFFFFFFD0;
  var1 = 0;
  ((int *) sp)[8] = fp;
  var2 = stream;
  var3 = 0;
  ((int *) sp)[7] = s7;
  var4 = 0;
  var5 = 0;
  ((int *) sp)[6] = s6;
  ((int *) sp)[5] = s5;
  ((int *) sp)[4] = s4;
  ((int *) sp)[3] = s3;
  ((int *) sp)[2] = s2;
  ((int *) sp)[1] = s1;
  ((int *) sp)[0] = s0;
  while (1) {
    var6 = ((int *) var2)[1];
    if(var6 == 0xFFFF0000)
    {
      var20 = ((int *) var2)[0];
      var21 = arg3;
      if(var20 == 0xBD400000)
      {
      label23:
        var3 = (var21 & 0xFFF00000) | (0 & 0x000FFFFF);
      label24:
        var4 = 0x0F;
      }
      else
      {
        if(((0xBD400000 < var20)) != 0)
        {
          var23 = arg3;
          if(var20 == 0xBD880000)
          {
          label12:
            var3 = (var23 & 0xFFF80000) | (0 & 0x0007FFFF);
            var4 = 0x07;
          }
          else
          {
            var3 = (var23 & 0xFFE00000) | (0 & 0x001FFFFF);
            if(((0xBD880000 < var20)) != 0)
            {
              var23 = arg3;
              if(var20 == 0xBD900000)
                goto label12;
              if(var20 != 0xBDA00000)
              {
                var22 = arg3;
              label26:
                var3 = (var22 & 0xFFFF0000) | (0 & 0x0000FFFF);
                var4 = 0;
              }
              else
              {
                var23 = arg3;
                goto label12;
              }
            }
            else
            {
              var4 = 0x1F;
              if(var20 != 0xBD800000)
              {
              label25:
                var22 = arg3;
                goto label26;
              }
              else
              {
              }
            }
          }
        }
        else
        {
          if(var20 == 0xBD100000)
          {
            var21 = arg3;
            goto label23;
          }
          else
          {
            if(((0xBD100000 < var20)) != 0)
            {
              var21 = arg3;
              if(var20 == 0xBD200000)
                goto label23;
              if(var20 != 0xBD300000)
              {
                var22 = arg3;
                goto label26;
              }
              else
              {
                var3 = (arg3 & 0xFFF00000) | (0 & 0x000FFFFF);
                goto label24;
              }
            }
            else
            {
              var21 = arg3;
              if(var20 == 0xBD000000)
                goto label23;
              goto label25;
            }
          }
        }
      }
      if(var3 != var20)
      {
        var5 = var5 + 1;
      }
      else
      {
        var17 = (arg3 >> 0x10) & var4;
      label37:
        ((int *) arg1)[0] = var5;
      label51:
        ((int *) arg2)[0] = var17;
      label52:
        var5 = var5 + 1;
      }
    }
    else
    {
      if(((0xFFFF0000 < var6)) != 0)
      {
        if(var6 == 0xFFFFFF00)
        {
          var19 = ((int *) var2)[0];
          if(var19 == 0xBF01E000)
          {
            var3 = (arg3 & 0xFFFFE000) | (0 & 0x00001FFF);
            var4 = 0x1F;
          }
          var17 = (arg3 >> 8) & var4;
          if(!(var3 != var19))
            goto label37;
          goto label52;
        }
        else
        {
          if(var6 != 0xFFFFFFFF)
          {
            var5 = var5 + 1;
          }
          else
          {
            var18 = ((int *) var2)[0];
            var3 = (arg3 & 0xFFFFFF00) | (0 & 0xFF);
            if(var3 != var18)
            {
              var5 = var5 + 1;
            }
            else
            {
              var1 = 1;
              ((int *) arg1)[0] = var5;
              ((int *) arg2)[0] = (arg3 & 0x0000FFFF);
              goto label52;
            }
          }
        }
      }
      else
      {
        if(!(var6 == 0xFF000000))
          goto label52;
        var16 = ((int *) var2)[0];
        var3 = (arg3 & 0xF0000000) | (0 & 0x0FFFFFFF);
        var4 = 0x0F;
        if(!(var16 == 0xE0000000))
        {
          var3 = (arg3 & 0xE0000000) | (0 & 0x1FFFFFFF);
          var4 = 0x1F;
          if(!(var16 == 0xC0000000))
          {
            var3 = (arg3 & 0xFF000000) | (0 & 0x00FFFFFF);
            var4 = 0;
          }
        }
        if(var3 != var16)
        {
          var5 = var5 + 1;
        }
        else
        {
          ((int *) arg1)[0] = var5;
          var17 = (arg3 >> 0x18) & var4;
          goto label51;
        }
      }
    }
    var2 = var2 + 8;
    if((((var5 < 0x13)) & ((var1 < 1))) != 0)
      continue;
    break;
  }
  var7 = ((int *) sp)[8];
  var8 = ((int *) sp)[7];
  var9 = ((int *) sp)[6];
  var10 = ((int *) sp)[5];
  var11 = ((int *) sp)[4];
  var12 = ((int *) sp)[3];
  var13 = ((int *) sp)[2];
  var14 = ((int *) sp)[1];
  var15 = ((int *) sp)[0];
  sp = sp + 0x30;
  return;
}
int getStreamOffset (int arg1){
  if(arg1>=0x13)return 0x806101FE;
  return ((int *) ((arg1 << 3) + stream))[1];
}
int be2 (int arg1){
  var1 = ((unsigned char *) arg1)[0];
  var2 = ((unsigned char *) arg1)[1];
  return ((var2 + (var1 << 8)) & 0x0000FFFF);
}
int be3 (int arg1){
  var1 = ((unsigned char *) arg1)[0];
  var2 = ((unsigned char *) arg1)[1];
  var3 = ((unsigned char *) arg1)[2];
  return (((var1 << 0x10) + (var2 << 8)) + var3);
}
int be4 (int arg1){
  var1 = ((unsigned char *) arg1)[0];
  var2 = ((unsigned char *) arg1)[1];
  var3 = ((unsigned char *) arg1)[2];
  var4 = ((unsigned char *) arg1)[3];
  return ((((var1 << 0x18) + (var2 << 0x10)) + (var3 << 8)) + var4);
}
int beN (int arg1, int arg2){
  var1 = arg1;
  if(arg2 == 2)
  {
    var10 = ((unsigned char *) arg1)[0];
    var11 = ((unsigned char *) arg1)[1];
    var2 = (var11 + (var10 << 8)) & 0x0000FFFF;
  }
  else
  {
    if(((arg2 < 3)) == 0)
    {
      if(arg2 == 3)
      {
        var7 = ((unsigned char *) arg1)[0];
        var8 = ((unsigned char *) arg1)[1];
        var9 = ((unsigned char *) arg1)[2];
        var2 = ((var7 << 0x10) + (var8 << 8)) + var9;
      }
      else
      {
        if(arg2 != 4)
        {
        label11:
          var2 = 0;
        }
        else
        {
          var3 = ((unsigned char *) arg1)[1];
          var4 = ((unsigned char *) arg1)[0];
          var5 = ((unsigned char *) arg1)[2];
          var6 = ((unsigned char *) var1)[3];
          var2 = (((var4 << 0x18) + (var3 << 0x10)) + (var5 << 8)) + var6;
        }
      }
    }
    else
    {
      if(!(arg2 == 1))
        goto label11;
      var2 = ((unsigned char *) var1)[0];
    }
  }
  return var2;
}
